mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
21 lines
520 B
JavaScript
21 lines
520 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const BbPromise = require('bluebird');
|
|
const fse = BbPromise.promisifyAll(require('fs-extra'));
|
|
|
|
const localNpmBinPath = path.join(__dirname, '../../node_modules/npm/bin/npm-cli.js');
|
|
|
|
module.exports = fse
|
|
.statAsync(localNpmBinPath)
|
|
.then(
|
|
stats => stats.isFile(),
|
|
error => {
|
|
if (error.code === 'ENOENT') return null;
|
|
throw error;
|
|
}
|
|
)
|
|
.then(isNpmInstalledLocaly => {
|
|
return isNpmInstalledLocaly ? `node ${localNpmBinPath}` : 'npm';
|
|
});
|