Created
September 24, 2017 20:34
-
-
Save tibawatanabe/c2e002dd02727ba5df74ee1bfe9216cf to your computer and use it in GitHub Desktop.
Node script to install peer-dependencies
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
'use strict' | |
const exec = require('child_process').exec; | |
const { promisify } = require('util'); | |
const execAsPromise = promisify(exec); | |
const packageJson = require('./package.json'); | |
const commands = Object.entries(packageJson.peerDependencies) | |
.map(([key, value]) => `npm install ${key}@${value}`) | |
.map(command => { | |
return Promise.resolve() | |
.then(() => console.log(`[BEGIN] ${command}`)) | |
.then(execAsPromise(command)) | |
.then(() => console.log(`[DONE] ${command}`)); | |
}); | |
async function install() { | |
try { | |
await Promise.all(commands); | |
console.log('Installed peer dependencies'); | |
} catch (err) { | |
console.error(err); | |
} | |
} | |
install().then(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment