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 4, 2018
1 parent 8682f57 commit ce02d99
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/copy-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@
*/

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];
assert(!tag || tag !== 'rc', 'Only "rc" tag is supported.');

assert(!package.publishConfig, 'Can not override "publishConfig".');
package.publishConfig = { tag: tag || 'latest' };

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

0 comments on commit ce02d99

Please sign in to comment.