Created
December 15, 2019 10:43
-
-
Save GiladShoham/6955339034fad045b988eeaefb869b8c to your computer and use it in GitHub Desktop.
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
//IMPORTANT - install this before: npm i child-process-promise --save-dev | |
/* | |
put this in your package.json script: | |
"install-collection": "node install-collection.js" | |
npm run install-collection <user>.<collection> | |
*/ | |
const exec = require('child-process-promise').exec; | |
const args = process.argv; | |
const remote = args[2]; | |
console.log('remote', remote); | |
exec(`bit list ${remote} -j`, {}).then(function (result) { | |
if(!amount) amount = 1; | |
const list = JSON.parse(result.stdout); | |
const components = list.map(compToNpmId); | |
const command = `npm install ${components.join(' ')}`; | |
installComponents(command); | |
}); | |
function installComponents(command) { | |
exec(command) | |
.then(function (result) { | |
var stdout = result.stdout; | |
var stderr = result.stderr; | |
console.log('stdout: ', stdout); | |
console.log('stderr: ', stderr); | |
}) | |
.catch(function (err) { | |
console.error('ERROR: ', err); | |
}); | |
} | |
function compToNpmId(component) { | |
return bitIdtoNpmId(component.id); | |
} | |
function bitIdtoNpmId(bitId) { | |
const doted = bitId.replace(/\//g, '.'); | |
return `@bit/${doted}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment