Skip to content

Commit

Permalink
fix: __dirname workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Mar 9, 2024
1 parent 60fca78 commit 59ebffb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import url from 'node:url';

import { copyAssets } from './app_assets.js';
import { findpath } from './findpath.js';

async function run() {
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
/* Rename nw.js's own package.json as workaround for https://github.com/nwjs/nw.js/issues/1503 */
const packagejson = path.resolve(__dirname, '..', 'package.json');
const packagejsonBackup = path.resolve(__dirname, '..', 'package_backup.json');
Expand Down
2 changes: 2 additions & 0 deletions lib/findpath.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import process from 'node:process';
import path from 'node:path';
import url from 'node:url';

/**
* Get the platform dependant path of the NW.js or ChromeDriver binary.
Expand All @@ -8,6 +9,7 @@ import path from 'node:path';
* @return {string}
*/
export function findpath(executable = 'nwjs') {
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const nwDir = path.resolve(__dirname, '..', 'nwjs');
/**
* File path to executable.
Expand Down
6 changes: 4 additions & 2 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { createWriteStream, existsSync } from 'node:fs';
import { rename, rm, symlink } from 'node:fs/promises';
import { get } from 'node:https';
import { resolve } from 'node:path';
import { arch, env, platform, exit } from 'node:process';
import { URL } from 'node:url';
import { arch, dirname, env, platform, exit } from 'node:process';
import { URL, fileURLToPath } from 'node:url';

import compressing from 'compressing';
import { SingleBar, Presets } from 'cli-progress';
import { parse } from 'semver';

import manifest from '../package.json' assert { type: 'json' };

const __dirname = dirname(fileURLToPath(import.meta.url));

install()
.catch((error) => {
if (error.code === 'EPERM') {
Expand Down

0 comments on commit 59ebffb

Please sign in to comment.