-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// cross-platform executable link, mostly for Windows | ||
// this file is dev-only. | ||
|
||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const cmdShim = require('util').promisify(require('cmd-shim')) | ||
|
||
exports.linkBin = async (src, dest) => { | ||
if (!process.env.NODEPACK_TEST && !process.env.NODEPACK_DEBUG) { | ||
throw new Error(`linkBin should only be used during tests or debugging.`) | ||
} | ||
if (process.platform === 'win32' && !process.env.CI) { | ||
// not doing mutex lock because this is only used in dev and the | ||
// src will not be modified | ||
await cmdShim(src, dest) | ||
} else { | ||
await fs.ensureDir(path.dirname(dest)) | ||
await fs.symlink(src, dest) | ||
await fs.chmod(dest, '755') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// dev only | ||
|
||
const path = require('path') | ||
const { linkBin } = require('./linkBin') | ||
|
||
/** | ||
* @param {string} targetDir | ||
*/ | ||
module.exports = function setupDevProject (targetDir) { | ||
return linkBin( | ||
require.resolve('@nodepack/service/src/bin/nodepack-service'), | ||
path.join(targetDir, 'node_modules', '.bin', 'nodepack-service') | ||
) | ||
} |