mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
projectInstall: fixed errors
This commit is contained in:
parent
68cb056389
commit
91f97dcd96
@ -352,6 +352,10 @@ module.exports = function(SPlugin, serverlessPath) {
|
||||
|
||||
return new BbPromise(function (resolve, reject) {
|
||||
|
||||
// create temp package.json for npm install
|
||||
let packageJson = SUtils.readAndParseJsonSync(path.join(_this.S.config.serverlessPath, 'templates', 'nodejs', 'package.json'));
|
||||
fs.writeFileSync(path.join(process.cwd(), 'package.json'), JSON.stringify(packageJson, null, 2));
|
||||
|
||||
let exec = require('child_process').exec,
|
||||
child;
|
||||
|
||||
@ -361,13 +365,16 @@ module.exports = function(SPlugin, serverlessPath) {
|
||||
if (error !== null) return reject(new SError(error));
|
||||
|
||||
try {
|
||||
fse.copySync(path.join(process.cwd(), 'node_modules'), process.cwd())
|
||||
fs.mkdirSync(path.join(process.cwd(), _this.evt.options.name));
|
||||
fse.copySync(path.join(process.cwd(), 'node_modules', _this.evt.options.project), path.join(process.cwd(), _this.evt.options.name));
|
||||
|
||||
} catch (err) {
|
||||
return reject(new SError(err))
|
||||
}
|
||||
|
||||
// Delete node_modules
|
||||
// Delete node_modules & package.json
|
||||
fse.removeSync(path.join(process.cwd(), 'node_modules'));
|
||||
fse.removeSync(path.join(process.cwd(), 'package.json'));
|
||||
|
||||
return resolve();
|
||||
})
|
||||
@ -419,12 +426,6 @@ module.exports = function(SPlugin, serverlessPath) {
|
||||
|
||||
return BbPromise.try(function() {
|
||||
|
||||
// Rename project dir
|
||||
fs.renameSync(
|
||||
path.join(process.cwd(), _this.evt.options.project),
|
||||
path.join(process.cwd(), _this.evt.options.name)
|
||||
);
|
||||
|
||||
// Rename .npmignore to .gitignore
|
||||
fs.renameSync(
|
||||
path.join(process.cwd(), _this.evt.options.name, '.npmignore'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user