forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tooling for vendored dependencies
- Loading branch information
1 parent
4f67207
commit 35179b6
Showing
5 changed files
with
66 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,6 @@ npm-debug.log | |
node_modules | ||
|
||
Keybase.app.dSYM.zip | ||
|
||
js-vendor-desktop | ||
node_shrinkwrap |
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,52 @@ | ||
#!/usr/bin/env node | ||
|
||
var os = require('os') | ||
var path = require('path') | ||
var fs = require('fs') | ||
var spawnSync = require('child_process').spawnSync | ||
|
||
function ensureSymlink (target, dest) { | ||
if (fs.existsSync(target)) { | ||
console.log('Removing existing', target) | ||
fs.unlinkSync(target) | ||
} | ||
|
||
var absDest = path.resolve(dest) | ||
console.log('Linking', target, '->', absDest) | ||
fs.symlinkSync(absDest, target) | ||
} | ||
|
||
function spawn (command, args, options) { | ||
console.log('>', command, args.join(' ')) | ||
var res = spawnSync(command, args, Object.assign({stdio: 'inherit', encoding: 'utf8'}, options)) | ||
if (res.error) { | ||
throw res.error | ||
} else if (res.status !== 0) { | ||
throw new Error('Unexpected exit code: ' + res.status) | ||
} | ||
} | ||
|
||
function installVendored () { | ||
var packageInfo = JSON.parse(fs.readFileSync('./package.json')) | ||
var parts = packageInfo.keybaseVendoredDependencies.split('#') | ||
var url = parts[0] | ||
var commit = parts[1] | ||
|
||
if (!fs.existsSync('./js-vendor-desktop')) { | ||
spawn('git', ['clone', url, 'js-vendor-desktop']) | ||
} | ||
spawn('git', ['fetch', 'origin'], {cwd: './js-vendor-desktop'}) | ||
spawn('git', ['checkout', '-f', commit], {cwd: './js-vendor-desktop'}) | ||
console.log(`js-vendor-desktop: ${url} @ ${commit}`) | ||
|
||
ensureSymlink('./npm-shrinkwrap.json', './js-vendor-desktop/npm-shrinkwrap.json') | ||
ensureSymlink('./node_shrinkwrap', './js-vendor-desktop/node_shrinkwrap') | ||
spawn(os.platform() === 'win32' ? 'npm.cmd' : 'npm', ['install', '--loglevel=http', '--no-optional'], { | ||
env: Object.assign({}, process.env, { | ||
ELECTRON_CACHE: path.resolve('./js-vendor-desktop/electron'), | ||
ELECTRON_ONLY_CACHE: 1, | ||
}), | ||
}) | ||
} | ||
|
||
installVendored() |
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