-
Notifications
You must be signed in to change notification settings - Fork 39
/
publish.js
37 lines (34 loc) · 1.57 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
34
35
36
37
const fs = require('fs');
const util = require('./common-npm-packages/build-scripts/util');
const releaseNotes = require('./common-npm-packages/build-scripts/create-release');
console.log('Publishing shared npm packages');
async function publishPackages(packages) {
for (let i = 0; i < packages.length; i++) {
const package = packages[i];
if (fs.statSync(package).isDirectory() && ['build-scripts', '.git', '_download', 'node_modules'].indexOf(package) < 0) {
console.log('\n----------------------------------');
console.log(package);
console.log('----------------------------------');
util.cd(package);
util.cd('_build');
try {
const npmrc = `//registry.npmjs.org/:_authToken=\${NPM_TOKEN}`;
console.log(`Writing .npmrc: ${npmrc}`);
fs.writeFileSync('.npmrc', npmrc);
util.run('npm publish --registry https://registry.npmjs.org/');
await releaseNotes.createReleaseNotes(package, 'main');
}
catch(ex) {
if (ex instanceof util.CreateReleaseError) {
console.log(`Error creating release notes: ${ex.message}`);
} else {
console.log('Publish failed - this usually indicates that the package has already been published');
}
}
util.cd('../..');
}
}
}
util.cd('common-npm-packages');
var packages = fs.readdirSync('./', { encoding: 'utf-8' });
publishPackages(packages);