diff --git a/package.json b/package.json index 397a738..ebf3076 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "declare": "tsc --declaration --emitDeclarationOnly --outDir \"./types\"", "build:win": "powershell -NoProfile -ExecutionPolicy Bypass -File ./src/build.ps1", "build:win:legacy": "call src\\build.cmd", - "build:linux": "sh src/build.sh" + "build:linux": "sh ./src/build.sh" }, "keywords": [ "regedit", diff --git a/src/build.sh b/src/build.sh index 00b4b2b..ed6510b 100644 --- a/src/build.sh +++ b/src/build.sh @@ -1,22 +1,23 @@ #!/bin/sh -CWD = "$(dirname "${BASH_SOURCE[0]}")" +CWD="$( dirname "${BASH_SOURCE[0]}" )" -cd CWD -export GOOS=windows -export CGO_ENABLED=1 +cd $CWD +export GOOS="windows" +export CGO_ENABLED="1" echo "Compiling x64..." -export GOARCH=amd64 -export CC=zig cc -target x86_64-windows-gnu -go build -buildmode=c-shared -o "$CWD/../dist/regodit.x64.dll" regodit +export GOARCH="amd64" +export CC="zig cc -target x86_64-windows-gnu" +go build -buildmode=c-shared -o "../dist/regodit.x64.dll" regodit echo "Compiling x86..." -export GOARCH=386 -export CC=zig cc -target x86-windows-gnu -go build -buildmode=c-shared -o "$CWD/../dist/regodit.x86.dll" regodit +export GOARCH="386" +export CC="zig cc -target i386-windows-gnu" + +go build -buildmode=c-shared -o "../dist/regodit.x86.dll" regodit echo "Compiling arm64..." -export GOARCH=arm64 -export CC=zig cc -target aarch64-windows-gnu -go build -buildmode=c-shared -o "$CWD/../dist/regodit.arm64.dll" regodit \ No newline at end of file +export GOARCH="arm64" +export CC="zig cc -target aarch64-windows-gnu" +go build -buildmode=c-shared -o "../dist/regodit.arm64.dll" regodit diff --git a/test/io.js b/test/io.js index 59fb4cf..0f96a8d 100644 --- a/test/io.js +++ b/test/io.js @@ -4,7 +4,7 @@ import { isWindows } from "@xan105/is"; import * as reg from "../lib/index.js"; test("Read/write REG_SZ", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/string"]; @@ -41,7 +41,7 @@ test("Read/write REG_SZ", { }); test("Read/write REG_MULTI_SZ", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/string"]; @@ -78,7 +78,7 @@ test("Read/write REG_MULTI_SZ", { }); test("Read/write REG_EXPAND_SZ", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/string"]; @@ -115,7 +115,7 @@ test("Read/write REG_EXPAND_SZ", { }); test("Read/write REG_BINARY", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/binary"]; @@ -147,7 +147,7 @@ test("Read/write REG_BINARY", { }); test("Read/write REG_DWORD & REG_QWORD", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/number"]; @@ -245,4 +245,4 @@ test("Read/write REG_DWORD & REG_QWORD", { assert.ok(!(await reg.promises.regKeyExists(...key))); }); -}); \ No newline at end of file +}); diff --git a/test/misc.js b/test/misc.js index 0048aa9..15b4d9d 100644 --- a/test/misc.js +++ b/test/misc.js @@ -4,9 +4,7 @@ import { userInfo } from "node:os"; import { isWindows } from "@xan105/is"; import * as reg from "../lib/index.js"; -test("Promises/Sync method count", { - skip: isWindows ? false : "This test runs on Windows" -}, () => { +test("Promises/Sync method count", () => { const promises = Object.keys(reg.promises).length; const sync = Object.keys(reg).length - 1; @@ -14,8 +12,19 @@ test("Promises/Sync method count", { }); +test("Linux fail at runtime", { + skip: !isWindows() ? false : "This test runs on Linux" +}, () => { + try{ + reg.regKeyExists("HKCU", "Software"); + }catch(err){ + assert.ok(err.code === "ERR_FFI"); + assert.ok(err.message.includes("cannot open shared object file")); + } +}); + test("Creating and deleting a key", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/create"] @@ -39,7 +48,7 @@ test("Creating and deleting a key", { }); test("Read string expand env var", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/Microsoft/Windows/CurrentVersion/Explorer/User Shell Folders", "AppData"]; @@ -58,7 +67,7 @@ test("Read string expand env var", { }); test("List subkeys / values", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { const key = ["HKCU", "Software/regodit/listing"]; @@ -97,7 +106,7 @@ test("List subkeys / values", { test("Import/Export", { - skip: isWindows ? false : "This test runs on Windows" + skip: isWindows() ? false : "This test runs on Windows" }, async () => { await test("sync", () => { @@ -128,4 +137,4 @@ test("Import/Export", { assert.ok(!(await reg.promises.regKeyExists("HKCU", "Software_Backup"))); }); -}); \ No newline at end of file +});