Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
🐛 redownload-electron-bins.js: Correct path
Browse files Browse the repository at this point in the history
Construct the atomRepoPath variable starting with __dirname,
so that atomRepoPath is an absolute path.

For example: '/Users/[username]/atom/package.json',
versus '../../../../atom/package.json'.

---

Explanation for why this is necessary:

The require() and fs.existsSync() functions interpret
relative paths differently.

require() is relative to the current script's containing folder,
(which is the same as __dirname),
whereas 'fs.existsSync()' is relative to the working directory
(which is the same as process.cwd()).

When constructing the path to the Atom repo's main package.json,
we should construct it as an absolute path, for consistency's sake.
Otherwise the script will error out, or use the wrong package.json.
  • Loading branch information
DeeDeeG committed Sep 29, 2020
1 parent a88381b commit f1d86dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion script/redownload-electron-bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (typeof(downloadMksnapshotPath) !== 'undefined') {
const path = require('path');
const fs = require('fs');

const atomRepoPath = path.join('..', '..', '..', '..', 'atom', 'package.json');
const atomRepoPath = path.join(__dirname, '..', '..', '..', '..', 'atom', 'package.json');
const electronVersion = fs.existsSync(atomRepoPath) ? require(atomRepoPath).electronVersion : '6.1.12'

This comment has been minimized.

Copy link
@Abolish0098
// TODO: Keep the above "electronVersion" in sync with "electronVersion" from Atom's package.json

Expand Down

0 comments on commit f1d86dc

Please sign in to comment.