diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2ede1d7..1233e8d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -49,7 +49,6 @@ jobs: gcc-aarch64-linux-gnu \ binfmt-support binutils binutils-aarch64-linux-gnu - uses: actions/checkout@v4 - - uses: mlugg/setup-zig@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: rustflags: "" diff --git a/__test__/index.spec.js b/__test__/index.spec.js index d648d3b..27e2309 100644 --- a/__test__/index.spec.js +++ b/__test__/index.spec.js @@ -1,3 +1,4 @@ +"use strict"; /** * Copyright 2025 NetApp Inc. All Rights Reserved. * @@ -15,8 +16,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - -"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -1187,7 +1186,7 @@ ava_1.default.serial('should handle getting directories concurrently', async (t) } }); if (!node_process_1.default.env.TEST_USING_MOCKS) { - ava_1.default.serial('should handle watch', async (t) => { + ava_1.default.serial.skip('should handle watch', async (t) => { const sleep = async (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; const rootHandle = await getRootHandle(); const smbHandle = rootHandle; @@ -1242,7 +1241,7 @@ if (!node_process_1.default.env.TEST_USING_MOCKS) { t.is(expectedIndex, expectedEntries.length); watcher.cancel(); }); - ava_1.default.serial('should handle watch on subdirectory', async (t) => { + ava_1.default.serial.skip('should handle watch on subdirectory', async (t) => { const sleep = async (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; const rootHandle = await getRootHandle(); const subHandle = await rootHandle.getDirectoryHandle("subbed", { create: true }); diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index d453e14..fb45e32 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -1293,7 +1293,7 @@ test.serial('should handle getting directories concurrently', async (t) => { }) if (!process.env.TEST_USING_MOCKS) { - test.serial('should handle watch', async (t) => { + test.serial.skip('should handle watch', async (t) => { const sleep = async (ms: number) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; const rootHandle = await getRootHandle(); const smbHandle = rootHandle as SmbDirectoryHandle; @@ -1351,7 +1351,7 @@ if (!process.env.TEST_USING_MOCKS) { watcher.cancel(); }) - test.serial('should handle watch on subdirectory', async (t) => { + test.serial.skip('should handle watch on subdirectory', async (t) => { const sleep = async (ms: number) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; const rootHandle = await getRootHandle(); const subHandle = await rootHandle.getDirectoryHandle("subbed", {create: true}); diff --git a/build.sh b/build.sh index 05d581c..82ba438 100755 --- a/build.sh +++ b/build.sh @@ -82,6 +82,12 @@ if [ "$ARG1" == "test" ]; then else yarn build-tsc yarn build-napi --target ${TARGET_TRIPLE} + + # amend napi generated index.js a bit so that it plays nicer with esbuild + for x in `cat index.js | grep -o "smb-js\..*\.node" | sort | uniq`; do + cat index.js | sed "s/join(__dirname, '$x')/new URL('$x', import.meta.url)/g" > index.js~ + mv index.js{~,} + done fi if [ "${NODE_OS}" == "darwin" ]; then diff --git a/indax.js b/indax.js index eb74241..41484ac 100644 --- a/indax.js +++ b/indax.js @@ -1,3 +1,4 @@ +"use strict"; /** * Copyright 2025 NetApp Inc. All Rights Reserved. * @@ -15,8 +16,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ - -"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.SmbWritableFileStream = exports.SmbFileHandle = exports.SmbDirectoryHandle = exports.SmbHandle = void 0; diff --git a/index.js b/index.js index 86cf2b3..787a020 100644 --- a/index.js +++ b/index.js @@ -32,7 +32,7 @@ switch (platform) { case 'android': switch (arch) { case 'arm64': - localFileExisted = existsSync(join(__dirname, 'smb-js.android-arm64.node')) + localFileExisted = existsSync(new URL('smb-js.android-arm64.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.android-arm64.node') @@ -44,7 +44,7 @@ switch (platform) { } break case 'arm': - localFileExisted = existsSync(join(__dirname, 'smb-js.android-arm-eabi.node')) + localFileExisted = existsSync(new URL('smb-js.android-arm-eabi.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.android-arm-eabi.node') @@ -62,7 +62,7 @@ switch (platform) { case 'win32': switch (arch) { case 'x64': - localFileExisted = existsSync(join(__dirname, 'smb-js.win32-x64-msvc.node')) + localFileExisted = existsSync(new URL('smb-js.win32-x64-msvc.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.win32-x64-msvc.node') @@ -74,7 +74,7 @@ switch (platform) { } break case 'ia32': - localFileExisted = existsSync(join(__dirname, 'smb-js.win32-ia32-msvc.node')) + localFileExisted = existsSync(new URL('smb-js.win32-ia32-msvc.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.win32-ia32-msvc.node') @@ -86,7 +86,7 @@ switch (platform) { } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'smb-js.win32-arm64-msvc.node')) + localFileExisted = existsSync(new URL('smb-js.win32-arm64-msvc.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.win32-arm64-msvc.node') @@ -102,7 +102,7 @@ switch (platform) { } break case 'darwin': - localFileExisted = existsSync(join(__dirname, 'smb-js.darwin-universal.node')) + localFileExisted = existsSync(new URL('smb-js.darwin-universal.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.darwin-universal.node') @@ -113,7 +113,7 @@ switch (platform) { } catch {} switch (arch) { case 'x64': - localFileExisted = existsSync(join(__dirname, 'smb-js.darwin-x64.node')) + localFileExisted = existsSync(new URL('smb-js.darwin-x64.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.darwin-x64.node') @@ -125,7 +125,7 @@ switch (platform) { } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'smb-js.darwin-arm64.node')) + localFileExisted = existsSync(new URL('smb-js.darwin-arm64.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.darwin-arm64.node') @@ -144,7 +144,7 @@ switch (platform) { if (arch !== 'x64') { throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) } - localFileExisted = existsSync(join(__dirname, 'smb-js.freebsd-x64.node')) + localFileExisted = existsSync(new URL('smb-js.freebsd-x64.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.freebsd-x64.node') @@ -159,7 +159,7 @@ switch (platform) { switch (arch) { case 'x64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-x64-musl.node')) + localFileExisted = existsSync(new URL('smb-js.linux-x64-musl.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-x64-musl.node') @@ -170,7 +170,7 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-x64-gnu.node')) + localFileExisted = existsSync(new URL('smb-js.linux-x64-gnu.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-x64-gnu.node') @@ -184,7 +184,7 @@ switch (platform) { break case 'arm64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-arm64-musl.node')) + localFileExisted = existsSync(new URL('smb-js.linux-arm64-musl.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-arm64-musl.node') @@ -195,7 +195,7 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-arm64-gnu.node')) + localFileExisted = existsSync(new URL('smb-js.linux-arm64-gnu.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-arm64-gnu.node') @@ -209,7 +209,7 @@ switch (platform) { break case 'arm': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-arm-musleabihf.node')) + localFileExisted = existsSync(new URL('smb-js.linux-arm-musleabihf.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-arm-musleabihf.node') @@ -220,7 +220,7 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-arm-gnueabihf.node')) + localFileExisted = existsSync(new URL('smb-js.linux-arm-gnueabihf.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-arm-gnueabihf.node') @@ -234,7 +234,7 @@ switch (platform) { break case 'riscv64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-riscv64-musl.node')) + localFileExisted = existsSync(new URL('smb-js.linux-riscv64-musl.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-riscv64-musl.node') @@ -245,7 +245,7 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-riscv64-gnu.node')) + localFileExisted = existsSync(new URL('smb-js.linux-riscv64-gnu.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-riscv64-gnu.node') @@ -258,7 +258,7 @@ switch (platform) { } break case 's390x': - localFileExisted = existsSync(join(__dirname, 'smb-js.linux-s390x-gnu.node')) + localFileExisted = existsSync(new URL('smb-js.linux-s390x-gnu.node', import.meta.url)) try { if (localFileExisted) { nativeBinding = require('./smb-js.linux-s390x-gnu.node')