Skip to content

Commit

Permalink
Automatically setup npm publish tag
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Sep 3, 2018
1 parent 6b11b3b commit e5839d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions resources/copy-package-json.js
Expand Up @@ -11,8 +11,20 @@
*/

const fs = require('fs');
const assert = require('assert');

const package = require('../package.json');
delete package.scripts;
delete package.devDependencies;

const { version } = package;
const match = /^[0-9]+\.[0-9]+\.[0-9]+-?([^.]*)/.exec(version);
assert(match, 'Version does not match semver spec.');
const tag = match[1];
if (tag) {
assert(tag !== 'rc', 'Only "rc" tag is supported.');
assert(!package.publishConfig, 'Can not override "publishConfig".');
package.publishConfig = { tag };
}

fs.writeFileSync('./dist/package.json', JSON.stringify(package, null, 2));

0 comments on commit e5839d8

Please sign in to comment.