Skip to content

Commit 8cf5f5d

Browse files
johnfarcanis
authored andcommitted
Ensure publish hooks are run at the same time. (#4553)
Move publish, prepublish and prepare hooks to run before tar ball is created. Also switch the order of prepare to be consistent with https://docs.npmjs.com/misc/scripts
1 parent 0415b07 commit 8cf5f5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cli/commands/publish.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ async function publish(config: Config, pkg: any, flags: Object, dir: string): Pr
3232
throw new MessageError(config.reporter.lang('invalidAccess'));
3333
}
3434

35+
// TODO this might modify package.json, do we need to reload it?
36+
await config.executeLifecycleScript('prepublish');
37+
await config.executeLifecycleScript('prepare');
38+
await config.executeLifecycleScript('prepublishOnly');
39+
3540
// get tarball stream
3641
const stat = await fs.lstat(dir);
3742
let stream;
@@ -60,11 +65,6 @@ async function publish(config: Config, pkg: any, flags: Object, dir: string): Pr
6065
const tbName = `${pkg.name}-${pkg.version}.tgz`;
6166
const tbURI = `${pkg.name}/-/${tbName}`;
6267

63-
// TODO this might modify package.json, do we need to reload it?
64-
await config.executeLifecycleScript('prepublish');
65-
await config.executeLifecycleScript('prepublishOnly');
66-
await config.executeLifecycleScript('prepare');
67-
6868
// create body
6969
const root = {
7070
_id: pkg.name,

0 commit comments

Comments
 (0)