Skip to content

Commit 05b7f6e

Browse files
feat(publish_yalc_package): do not move to temp dir when unnecessary
1 parent de59d18 commit 05b7f6e

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

publish_yalc_package.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,27 @@ function publishYalcPackage(installTargetDir, installSource, flags) {
7979
const TEMP = tmp.dirSync();
8080
const TEMP_DIR = TEMP.name;
8181
const BUILD_TEMP_DIR = path.resolve(TEMP_DIR, path.basename(installTargetDir));
82-
try {
83-
shelljs.mv(installTargetDir, TEMP_DIR);
84-
process.chdir(BUILD_TEMP_DIR);
85-
86-
if (!flags.noBuild) {
87-
// Build package
88-
const pkgJson = JSON.parse(fs.readFileSync('package.json'));
89-
if (pkgJson.scripts && pkgJson.scripts.build) {
90-
util._exec('npm run build');
82+
if (!flags.noBuild || !flags.noPublish) {
83+
try {
84+
shelljs.mv(installTargetDir, TEMP_DIR);
85+
process.chdir(BUILD_TEMP_DIR);
86+
87+
if (!flags.noBuild) {
88+
// Build package
89+
const pkgJson = JSON.parse(fs.readFileSync('package.json'));
90+
if (pkgJson.scripts && pkgJson.scripts.build) {
91+
util._exec('npm run build');
92+
}
9193
}
92-
}
9394

94-
if (!flags.noPublish) {
95-
// Publish to local yalc registry
96-
util._exec('npx yalc publish');
95+
if (!flags.noPublish) {
96+
// Publish to local yalc registry
97+
util._exec('npx yalc publish');
98+
}
99+
} finally {
100+
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);
101+
shelljs.rm('-rf', TEMP_DIR);
97102
}
98-
} finally {
99-
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);
100-
shelljs.rm('-rf', TEMP_DIR);
101103
}
102104

103105
process.chdir(ORIG_DIR);

0 commit comments

Comments
 (0)