diff --git a/lib/is-server-package.js b/lib/is-server-package.js deleted file mode 100644 index c36c40d..0000000 --- a/lib/is-server-package.js +++ /dev/null @@ -1,11 +0,0 @@ -const { stat } = require('node:fs/promises') -const { resolve } = require('node:path') - -module.exports = async path => { - try { - const st = await stat(resolve(path, 'server.js')) - return st.isFile() - } catch (er) { - return false - } -} diff --git a/lib/run-script-pkg.js b/lib/run-script-pkg.js index 161caeb..64018b0 100644 --- a/lib/run-script-pkg.js +++ b/lib/run-script-pkg.js @@ -3,7 +3,6 @@ const promiseSpawn = require('@npmcli/promise-spawn') const packageEnvs = require('./package-envs.js') const { isNodeGypPackage, defaultGypInstallScript } = require('@npmcli/node-gyp') const signalManager = require('./signal-manager.js') -const isServerPackage = require('./is-server-package.js') const runScriptPkg = async options => { const { @@ -37,8 +36,6 @@ const runScriptPkg = async options => { await isNodeGypPackage(path) ) { cmd = defaultGypInstallScript - } else if (event === 'start' && await isServerPackage(path)) { - cmd = 'node server.js' } if (!cmd) { diff --git a/lib/run-script.js b/lib/run-script.js index b00304c..625f2e4 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -1,7 +1,6 @@ const PackageJson = require('@npmcli/package-json') const runScriptPkg = require('./run-script-pkg.js') const validateOptions = require('./validate-options.js') -const isServerPackage = require('./is-server-package.js') const runScript = async options => { validateOptions(options) @@ -12,4 +11,4 @@ const runScript = async options => { return runScriptPkg({ ...options, pkg }) } -module.exports = Object.assign(runScript, { isServerPackage }) +module.exports = runScript diff --git a/test/run-script.js b/test/run-script.js index c63a4cb..abc6230 100644 --- a/test/run-script.js +++ b/test/run-script.js @@ -74,9 +74,8 @@ t.test('run-script', async t => { t.strictSame(res, { code: 0, signal: null }) }) - await t.test('start event, pkg has server.js but no start script', async t => { + await t.test('start event, pkg has no start script, early exit', async t => { const path = t.testdir({ 'server.js': '' }) - spawk.spawn(/.*/, a => a.includes('node server.js')) const res = await runScript({ event: 'start', path, @@ -85,11 +84,7 @@ t.test('run-script', async t => { scripts: {}, }, }) - t.match(res, { - event: 'start', - script: 'node server.js', - pkgid: '@npmcli/run-script-test@1.2.3', - }) + t.strictSame(res, { code: 0, signal: null }) }) await t.test('pkg does not have requested script, with custom cmd', async t => { @@ -111,22 +106,3 @@ t.test('run-script', async t => { t.ok(spawk.done()) }) }) - -t.test('isServerPackage', async t => { - await t.test('is server package', async t => { - const testdir = t.testdir({ - 'server.js': '', - }) - await t.resolves(runScript.isServerPackage(testdir), true) - }) - await t.test('is not server package - no server.js', async t => { - const testdir = t.testdir({}) - await t.resolves(runScript.isServerPackage(testdir), false) - }) - await t.test('is not server package - invalid server.js', async t => { - const testdir = t.testdir({ - 'server.js': {}, - }) - await t.resolves(runScript.isServerPackage(testdir), false) - }) -})