Skip to content

Commit

Permalink
fix(build): update module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Apr 12, 2024
1 parent 13fdce2 commit 305e543
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
20 changes: 11 additions & 9 deletions lib/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const process = require("node:process");

const _ = require("lodash");
const glob = require("simple-glob");
const fs = require("graceful-fs-extra");
const gfs = require("graceful-fs-extra");
const thenify = require("thenify");
const rcedit = require("rcedit");
const winresourcer = thenify(require("winresourcer"));
Expand Down Expand Up @@ -38,6 +38,8 @@ class NwBuilder {
)
delete this._platforms[name];
}
}).catch((error) => {
console.error(error);
});
}

Expand Down Expand Up @@ -335,10 +337,10 @@ class NwBuilder {
);

// Ensure that there is a release Folder, delete and create it.
fs.remove(platform.releasePath, function (err) {
gfs.remove(platform.releasePath, function (err) {
if (err) return reject(err);

fs.mkdirp(platform.releasePath, function (err) {
gfs.mkdirp(platform.releasePath, function (err) {
if (err) return reject(err);

log.debug("Create release folder in " + platform.releasePath);
Expand All @@ -357,12 +359,12 @@ class NwBuilder {
const platform = os.slice(0, os.length - 2);
const arch = "x" + os.slice(os.length - 2);

await fs.promises.rm(resolve(this.options.buildDir, this.options.appName, os), {
await fs.promises.rm(path.resolve(this.options.buildDir, this.options.appName, os), {
recursive: true,
force: true,
});

const nwDir = resolve(
const nwDir = path.resolve(
this.options.cacheDir,
`nwjs${this.options.flavor === "sdk" ? "-sdk" : ""}-v${
this.options.version
Expand All @@ -371,14 +373,14 @@ class NwBuilder {

await fs.promises.cp(
nwDir,
resolve(this.options.buildDir, this.options.appName, os),
path.resolve(this.options.buildDir, this.options.appName, os),
{ recursive: true },
);

for (const file of glob(this.options.files)) {
await fs.promises.cp(
file,
resolve(
path.resolve(
this.options.buildDir,
this.options.appName,
os,
Expand Down Expand Up @@ -577,8 +579,8 @@ class NwBuilder {
var executableName = self.getExecutableName(name);

await fs.promises.rename(
resolve(platform.releasePath, "nw"),
resolve(platform.releasePath, executableName),
path.resolve(platform.releasePath, "nw"),
path.resolve(platform.releasePath, executableName),
);
});
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"test:prep": "esbuild src/index.js --bundle --platform=node --outfile=./dist/index.cjs",
"test:unit": "node --test test/unit/detectCurrentPlatform.js ",
"test:tape": "tape './test/*.cjs'",
"test:sanity": "node --test-reporter=spec --test e2e/test.js"
"test:sanity": "node --test-reporter=spec --test e2e/test.js",
"demo": "cd test && node demo.cjs"
},
"devDependencies": {
"decompress-zip": "^0.3.3",
Expand Down
9 changes: 9 additions & 0 deletions test/demo.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const NwBuilder = require('nw-builder');
const { version } = require('yargs');

const nw = new NwBuilder({
version: '0.86.0',
files: './fixtures/demo/**',
});

nw.build();

0 comments on commit 305e543

Please sign in to comment.