Nicola Peduzzi
8 years ago
3 changed files with 34 additions and 5 deletions
@ -1,15 +1,43 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
const BbPromise = require('bluebird'); |
const BbPromise = require('bluebird'); |
||||
|
const path = require('path'); |
||||
const fse = require('fs-extra'); |
const fse = require('fs-extra'); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
cleanup() { |
cleanup() { |
||||
const webpackOutputPath = this.webpackOutputPath; |
const webpackOutputPath = this.webpackOutputPath; |
||||
|
|
||||
if (this.serverless.utils.dirExistsSync(webpackOutputPath)) { |
const moveArtifact = new BbPromise((resolve, reject) => { |
||||
fse.removeSync(webpackOutputPath); |
if (this.originalServicePath) { |
||||
} |
this.serverless.config.servicePath = this.originalServicePath; |
||||
return BbPromise.resolve(); |
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