Last active
January 28, 2016 08:50
-
-
Save shokai/fc08b63dec4c3a4d5282 to your computer and use it in GitHub Desktop.
run command in each packages of lerna
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
| #!/usr/bin/env node | |
| "use strict"; | |
| var path = require("path"); | |
| var fs = require("fs"); | |
| var spawn = require("child_process").spawn; | |
| var async = require("async"); | |
| var pkgs = fs.readdirSync(path.resolve(__dirname + "/../packages/")); | |
| var each = async.eachSeries; | |
| var args = process.argv.slice(2); | |
| if(args[0] === "--parallel"){ | |
| each = async.each; | |
| args.shift(); | |
| } | |
| var cmd = args.join(' '); | |
| console.log("command: " + cmd); | |
| console.log("packages: " + JSON.stringify(pkgs)); | |
| if(cmd.length < 1) process.exit(0); | |
| each(pkgs, function(pkg, next){ | |
| var pkgdir = path.resolve(__dirname + "/../packages", pkg); | |
| var _spawn = spawn("sh", ["-c", cmd], { | |
| cwd: pkgdir, | |
| stdio: ['pipe', process.stdout, process.stderr], | |
| env: process.env | |
| }) | |
| _spawn.on("close", next); | |
| }, function(err, res){ | |
| if(err) console.error(err); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lerna
each
parallel