Skip to content

Commit

Permalink
fix linux usage
Browse files Browse the repository at this point in the history
  • Loading branch information
xan105 committed Dec 4, 2023
1 parent 8b47b0c commit c3fa5f3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 14 additions & 13 deletions src/build.sh
Original file line number Diff line number Diff line change
@@ -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
export GOARCH="arm64"
export CC="zig cc -target aarch64-windows-gnu"
go build -buildmode=c-shared -o "../dist/regodit.arm64.dll" regodit
12 changes: 6 additions & 6 deletions test/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -245,4 +245,4 @@ test("Read/write REG_DWORD & REG_QWORD", {
assert.ok(!(await reg.promises.regKeyExists(...key)));
});

});
});
25 changes: 17 additions & 8 deletions test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ 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;
assert.ok(promises === sync);

});

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"]
Expand All @@ -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"];
Expand All @@ -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"];
Expand Down Expand Up @@ -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", () => {
Expand Down Expand Up @@ -128,4 +137,4 @@ test("Import/Export", {
assert.ok(!(await reg.promises.regKeyExists("HKCU", "Software_Backup")));
});

});
});

0 comments on commit c3fa5f3

Please sign in to comment.