-
Notifications
You must be signed in to change notification settings - Fork 21
/
publish.js
33 lines (29 loc) · 1.05 KB
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path');
var packagesDir = path.resolve(process.cwd(), './packages');
var copyCreds = 'cp ../../.npmrc .';
var publishAll = 'npm publish ' + process.argv.slice(2).join(' ');
// taken from: https://stackoverflow.com/questions/18112204/get-all-directories-within-directory-nodejs
const getDirectories = srcPath =>
fs.readdirSync(srcPath)
.filter(file => fs.statSync(path.join(srcPath, file)).isDirectory());
getDirectories(packagesDir).forEach(dir => {
const opts = {
cwd: path.resolve(packagesDir, './' + dir)
};
console.log('Copying Credentials for:', dir);
exec(copyCreds, opts, function(credErr, credOut) {
console.log(credOut);
if (credErr) {
console.warn('Suppressing Credentials Error', credErr);
}
console.log('Publishing', dir);
exec(publishAll, opts, function(publishErr, publishOut) {
console.log(publishOut);
if (publishErr) {
console.warn('Suppressing Publish Error', publishErr);
}
});
});
});