Skip to content

Commit 3e1c3d4

Browse files
Automatically setup npm publish tag (#1502)
Prevents issues similar to #1375 See: https://docs.npmjs.com/files/package.json#publishconfig
1 parent ab4e495 commit 3e1c3d4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

resources/copy-package-json.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@
1111
*/
1212

1313
const fs = require('fs');
14+
const assert = require('assert');
1415

1516
const package = require('../package.json');
1617
delete package.scripts;
1718
delete package.devDependencies;
19+
20+
const { version } = package;
21+
const match = /^[0-9]+\.[0-9]+\.[0-9]+-?([^.]*)/.exec(version);
22+
assert(match, 'Version does not match semver spec.');
23+
const tag = match[1];
24+
assert(!tag || tag === 'rc', 'Only "rc" tag is supported.');
25+
26+
assert(!package.publishConfig, 'Can not override "publishConfig".');
27+
package.publishConfig = { tag: tag || 'latest' };
28+
1829
fs.writeFileSync('./dist/package.json', JSON.stringify(package, null, 2));

0 commit comments

Comments
 (0)