1 Star 0 Fork 8

鲲鹏/FabricJS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
publish.js 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
var cp = require('child_process');
var path = require('path');
var fs = require('fs');
// useful changelog regexp for atom
// \(#([0-9]+)\) [#$1](https://github.com/fabricjs/fabric.js/pull/$1)
// eslint-disable-next-line no-undef
var pkgPath = path.resolve(__dirname, './package.json');
var pkgText = fs.readFileSync(pkgPath); // get original pkg text to restore it later
var pkgObject = JSON.parse(pkgText); // parsed pkg to override its fields
var args = process.argv.slice(2).join(' '); // args will be passed to npm publish (like --dry-run)
var preRelease = process.env.PRE_RELEASE;
// allow publishing of pre-releases with beta tag
if (preRelease === 'true') {
console.log('Adding beta tag to NPM publish');
args = '--tag beta ' + args;
}
// override package.json with updated fields
fs.writeFileSync(
pkgPath,
JSON.stringify(Object.assign(pkgObject, {
optionalDependencies: {},
version: pkgObject.version + '-browser',
}), null, '\t')
);
console.log('npm publish ' + args);
// publish -browser version
cp.execSync('npm publish ' + args);
console.log('Browser package is published');
// restore the original package.json contents
fs.writeFileSync(pkgPath, pkgText);
// publish the main version (the package is published "above" the -browser version)
cp.execSync('npm publish ' + args);
console.log('Main package is published');
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/garenx/FabricJS.git
git@gitee.com:garenx/FabricJS.git
garenx
FabricJS
FabricJS
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385