Nicola Peduzzi
8 years ago
3 changed files with 34 additions and 5 deletions
@ -1,15 +1,43 @@ |
|||
'use strict'; |
|||
|
|||
const BbPromise = require('bluebird'); |
|||
const path = require('path'); |
|||
const fse = require('fs-extra'); |
|||
|
|||
module.exports = { |
|||
cleanup() { |
|||
const webpackOutputPath = this.webpackOutputPath; |
|||
|
|||
if (this.serverless.utils.dirExistsSync(webpackOutputPath)) { |
|||
fse.removeSync(webpackOutputPath); |
|||
} |
|||
return BbPromise.resolve(); |
|||
const moveArtifact = new BbPromise((resolve, reject) => { |
|||
if (this.originalServicePath) { |
|||
this.serverless.config.servicePath = this.originalServicePath; |
|||
fse.move( |
|||
path.join(webpackOutputPath, '.serverless'), |
|||
path.join(this.serverless.config.servicePath, '.serverless'), |
|||
(err) => { |
|||
if (err) { |
|||
reject(err); |
|||
} else { |
|||
this.serverless.service.package.artifact = path.join( |
|||
this.serverless.config.servicePath, |
|||
'.serverless', |
|||
path.basename(this.serverless.service.package.artifact) |
|||
); |
|||
resolve(); |
|||
} |
|||
} |
|||
); |
|||
} else { |
|||
resolve(); |
|||
} |
|||
}); |
|||
|
|||
return moveArtifact |
|||
.then(() => { |
|||
if (this.serverless.utils.dirExistsSync(webpackOutputPath)) { |
|||
fse.removeSync(webpackOutputPath); |
|||
} |
|||
}) |
|||
.then(() => BbPromise.resolve()); |
|||
}, |
|||
}; |
|||
|
Loading…
Reference in new issue