-
-
Save apollwebservices/68f698acc162370b44da7c33b7a82730 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
| */ | |
| /*jshint esversion: 6 */ | |
| 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) { | |
| 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}`; | |
| } |
This file contains hidden or 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
| { | |
| "version": "0.0.4", | |
| "name": "install-bit-collection", | |
| "main": "install-collection.js", | |
| "dependencies": { | |
| "child-process-promise": "^2.2.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment