nw 0.81.0-3 → 0.81.0-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- var fs = require('fs');
4
- var path = require('path');
5
- var spawn = require('child_process').spawn;
6
- var bin = require('../lib/findpath.js')();
3
+ const { spawn } = require('node:child_process');
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+ const process = require('node:process');
7
+
8
+ const { copyAssets } = require('../lib/app_assets.js');
9
+ const findpath = require('../lib/findpath.js').findpath;
7
10
 
8
11
  function run() {
9
12
  // Rename nw.js's own package.json as workaround for https://github.com/nwjs/nw.js/issues/1503
@@ -16,7 +19,7 @@ function run() {
16
19
  }
17
20
 
18
21
  // copy over any asset files (icons, etc) specified via CLI args:
19
- require('../lib/app_assets').copyAssets(process.platform, bin);
22
+ copyAssets(process.platform, findpath());
20
23
 
21
24
  // Normalize cli args
22
25
  var args = process.argv.slice(2);
@@ -28,7 +31,7 @@ function run() {
28
31
  }
29
32
 
30
33
  // Spawn node-webkit
31
- var nw = spawn(bin, args, { stdio: 'inherit' });
34
+ var nw = spawn(findpath(), args, { stdio: 'inherit' });
32
35
  nw.on('close', function() {
33
36
  process.nextTick(function() {
34
37
  process.exit(0);
@@ -45,7 +48,7 @@ function run() {
45
48
  }, 1000);
46
49
  }
47
50
 
48
- if (!fs.existsSync(bin)) {
51
+ if (!fs.existsSync(findpath())) {
49
52
  console.log('nw.js appears to have failed to download and extract. Attempting to download and extract again...');
50
53
  var child = spawn(process.execPath, [path.resolve(__dirname, '..', 'scripts', 'install.js')], { stdio: 'inherit' });
51
54
  child.on('close', run);
@@ -1,7 +1,5 @@
1
- import { dirname } from 'node:path';
2
- import { env, platform } from 'node:process';
3
- import { join, resolve } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
1
+ const { env, platform } = require('node:process');
2
+ const { join, resolve } = require('node:path');
5
3
 
6
4
  /**
7
5
  * Get the platform dependant path of the NW.js or ChromeDriver binary.
@@ -9,8 +7,7 @@ import { fileURLToPath } from 'node:url';
9
7
  * @param {'nwjs' | 'chromedriver'} executable Path to NW.js or Chromedriver executable.
10
8
  * @return {string}
11
9
  */
12
- export default function findpath(executable = 'nwjs') {
13
- const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ function findpath(executable = 'nwjs') {
14
11
  const nwDir = resolve(__dirname, '..', 'nwjs');
15
12
  /**
16
13
  * File path to executable.
@@ -56,3 +53,5 @@ export default function findpath(executable = 'nwjs') {
56
53
 
57
54
  return binPath;
58
55
  }
56
+
57
+ module.exports = { findpath };
@@ -1,17 +1,19 @@
1
- import { createWriteStream, existsSync } from 'node:fs';
2
- import { rename, rm } from 'node:fs/promises';
3
- import { get } from 'node:https';
4
- import { dirname, resolve } from 'node:path';
5
- import { arch, env, platform, exit } from 'node:process';
6
- import { fileURLToPath, URL } from 'node:url';
1
+ const { createWriteStream, existsSync } = require('node:fs');
2
+ const { rename, rm } = require('node:fs/promises');
3
+ const { get } = require('node:https');
4
+ const { resolve } = require('node:path');
5
+ const { arch, env, platform, exit } = require('node:process');
6
+ const { URL } = require('node:url');
7
7
 
8
- import compressing from 'compressing';
9
- import progress from 'cli-progress';
10
- import semver from 'semver';
8
+ const compressing = require('compressing');
9
+ const progress = require('cli-progress');
10
+ const semver = require('semver');
11
11
 
12
- import nodeManifest from '../package.json' assert { type: 'json' };
12
+ const nodeManifest = require('../package.json');
13
13
 
14
- await install();
14
+ install()
15
+ .then(() => {})
16
+ .catch((error) => console.error(error));
15
17
 
16
18
  async function install() {
17
19
 
@@ -27,8 +29,6 @@ async function install() {
27
29
  arm64: 'arm64',
28
30
  };
29
31
 
30
- const __dirname = dirname(fileURLToPath(import.meta.url));
31
-
32
32
  /**
33
33
  * URL to download or get binaries from.
34
34
  *
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "nw",
3
- "version": "0.81.0-3",
3
+ "version": "0.81.0-4",
4
4
  "description": "A installer for nw.js",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git://github.com/nwjs/npm-installer.git"
8
8
  },
9
- "main": "lib/findpath.mjs",
9
+ "main": "lib/findpath.js",
10
10
  "bin": {
11
- "nw": "bin/nw"
11
+ "nw": "bin/nw.js"
12
12
  },
13
13
  "scripts": {
14
- "postinstall": "node lib/install.mjs",
15
- "test": "node --test-reporter=spec --test test/index.mjs"
14
+ "postinstall": "node lib/install.js",
15
+ "test": "node --test-reporter=spec --test test/index.js",
16
+ "dry-run": "nw ./test/app"
16
17
  },
17
18
  "files": [
18
19
  "lib",