mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fixes Function and Project classes
This commit is contained in:
parent
eeb8505b3e
commit
35ea983080
@ -171,7 +171,8 @@ class ServerlessFunction {
|
||||
|
||||
while( !_this._S.classes.Component.isComponentDir( p ) ) {
|
||||
if( SUtils.fileExistsSync(path.join(p, 's-templates.json'))) {
|
||||
templates.unshift( require(path.join(p, 's-templates.json')) );
|
||||
let template = JSON.parse(fs.readFileSync(path.join(p, 's-templates.json'), 'utf8'));
|
||||
templates.unshift(template);
|
||||
}
|
||||
p = path.join( p, '..' );
|
||||
}
|
||||
@ -266,10 +267,7 @@ class ServerlessFunction {
|
||||
// Populate
|
||||
let clone = _this.get();
|
||||
clone = SUtils.populate(_this._S.state.getMeta(), _this.getTemplates(), clone, options.stage, options.region);
|
||||
clone.endpoints = [];
|
||||
for (let i = 0; i < _this.endpoints.length; i++) {
|
||||
clone.endpoints[i] = _this.endpoints[i].getPopulated(options);
|
||||
}
|
||||
clone.endpoints = _this.endpoints.map( endpoint => endpoint.getPopulated(options) );
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@ -299,7 +299,7 @@ class ServerlessProject extends VarContainer {
|
||||
resources = SUtils.readAndParseJsonSync(_this._S.getProject().getFilePath('s-resources-cf.json'));
|
||||
}
|
||||
|
||||
return _.flatten( _.map( _.values( _this.components ), c => c.getCFSnippets() ) );
|
||||
return _.flattenDeep( _.map( _.values( _this.components ), c => c.getCFSnippets() ) );
|
||||
})
|
||||
.then(function (cfSnippets) {
|
||||
|
||||
@ -477,7 +477,7 @@ class ServerlessProject extends VarContainer {
|
||||
|
||||
getAllComponents(options){
|
||||
if( _.get( options, 'paths' ) ){
|
||||
options.paths = _.map( options.paths, p => p.split(path.sep)[0] );
|
||||
options.paths = _.map( options.paths, p => p && p.split(path.sep)[0] );
|
||||
}
|
||||
return SUtils.filterSPaths( _.values( this.components ), options );
|
||||
}
|
||||
@ -535,7 +535,7 @@ class ServerlessProject extends VarContainer {
|
||||
}
|
||||
|
||||
getRegion( stageName, regionName ){
|
||||
if( this.hasStage( stageName ) ){
|
||||
if( this.validateStageExists( stageName ) ){
|
||||
let stage = this.getStage( stageName );
|
||||
|
||||
if( stage.hasRegion( regionName ) ){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user