diff --git a/src/api/install.ts b/src/api/install.ts index 9661e7b1a4..ba6477f96b 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -114,6 +114,11 @@ export async function install (maybeOpts?: PnpmOptions) { async function run () { const scripts = !opts.ignoreScripts && ctx.pkg && ctx.pkg.scripts || {} + + if (scripts['prepublish']) { + logger.warn('`prepublish` scripts are deprecated. Use `prepare` for build steps and `prepublishOnly` for upload-only.') + } + if (scripts['preinstall']) { npmRun('preinstall', ctx.root, opts.userAgent) } @@ -126,6 +131,9 @@ export async function install (maybeOpts?: PnpmOptions) { if (scripts['prepublish']) { npmRun('prepublish', ctx.root, opts.userAgent) } + if (scripts['prepare']) { + npmRun('prepare', ctx.root, opts.userAgent) + } } }, {stale: opts.lockStaleDuration}) } diff --git a/test/install/lifecycleScripts.ts b/test/install/lifecycleScripts.ts index 7c8509d9d9..09a8aff444 100644 --- a/test/install/lifecycleScripts.ts +++ b/test/install/lifecycleScripts.ts @@ -124,32 +124,32 @@ test('postinstall is not executed after named installation', t => { t.end() }) -test('prepublish is not executed after installation with arguments', t => { +test('prepare is not executed after installation with arguments', t => { const project = prepare(t, { scripts: { - prepublish: 'echo "Hello world!"' + prepare: 'echo "Hello world!"' } }) const result = execPnpmSync('install', 'is-negative') t.equal(result.status, 0, 'installation was successfull') - t.ok(result.stdout.toString().indexOf('Hello world!') === -1, 'prepublish script was not executed') + t.ok(result.stdout.toString().indexOf('Hello world!') === -1, 'prepare script was not executed') t.end() }) -test('prepublish is executed after argumentless installation', t => { +test('prepare is executed after argumentless installation', t => { const project = prepare(t, { scripts: { - prepublish: 'echo "Hello world!"' + prepare: 'echo "Hello world!"' } }) const result = execPnpmSync('install') t.equal(result.status, 0, 'installation was successfull') - t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'prepublish script was executed') + t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'prepare script was executed') t.end() })