Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
chore(repo): update publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Jul 3, 2021
1 parent ea54ed7 commit 3f9b088
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tools/scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ const { readFileSync, writeFileSync, existsSync } = require('fs');

const { join } = require('path');

function publish(dir, tag) {
execSync(`npm publish ${dir} --access public --tag ${tag}`);
}

function updatePackageJson(packageJsonPath, version) {
function updatePackageJson(packageJsonPath, version, isDist) {
const packageJson = JSON.parse(readFileSync(packageJsonPath).toString());
packageJson.version = version;
if (isDist) {
Object.keys(packageJson.dependencies).forEach((k) => {
if (k === '@nrwl/detox') {
packageJson.dependencies[k] = version;
}
});
}
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
}

Expand All @@ -36,6 +39,8 @@ if (!existsSync(outputPath)) {
}

const root = projectMeta.root;

updatePackageJson(join(root, 'package.json'), version);
updatePackageJson(join(outputPath, 'package.json'), version);
publish(outputPath, tag);
updatePackageJson(join(outputPath, 'package.json'), version, true);

execSync(`npm publish ${outputPath} --access public --tag ${tag}`);

0 comments on commit 3f9b088

Please sign in to comment.