Skip to content

Commit

Permalink
Automatically setup npm publish tag (graphql#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Sep 10, 2018
1 parent ab4e495 commit 3e1c3d4
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 3e1c3d4

Please sign in to comment.