mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Merge pull request #3064 from vladgolubev/add-support-numeric-template-path
Add support of numeric template creation path
This commit is contained in:
commit
112cf554bd
@ -3,6 +3,7 @@
|
||||
const BbPromise = require('bluebird');
|
||||
const path = require('path');
|
||||
const fse = require('fs-extra');
|
||||
const _ = require('lodash');
|
||||
|
||||
// class wide constants
|
||||
const validTemplates = [
|
||||
@ -66,9 +67,8 @@ class Create {
|
||||
}
|
||||
|
||||
// store the custom options for the service if given
|
||||
const boilerplatePath = this.options
|
||||
.path && this.options.path.length ? this.options.path : null;
|
||||
const serviceName = this.options.name && this.options.name.length ? this.options.name : null;
|
||||
const boilerplatePath = _.toString(this.options.path);
|
||||
const serviceName = _.toString(this.options.name);
|
||||
|
||||
// create (if not yet present) and chdir into the directory for the service
|
||||
if (boilerplatePath) {
|
||||
|
||||
@ -311,6 +311,30 @@ describe('Create', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a service in the directory if using the "path" option with digits', () => {
|
||||
const cwd = process.cwd();
|
||||
fse.mkdirsSync(tmpDir);
|
||||
process.chdir(tmpDir);
|
||||
|
||||
create.options.path = 123;
|
||||
create.options.name = null;
|
||||
|
||||
// using the nodejs template (this test is completely be independent from the template)
|
||||
create.options.template = 'aws-nodejs';
|
||||
|
||||
return create.create().then(() => {
|
||||
const serviceDir = path.join(tmpDir, String(create.options.path));
|
||||
|
||||
// check if files are created in the correct directory
|
||||
expect(create.serverless.utils.fileExistsSync(
|
||||
path.join(serviceDir, 'serverless.yml'))).to.be.equal(true);
|
||||
expect(create.serverless.utils.fileExistsSync(
|
||||
path.join(serviceDir, 'handler.js'))).to.be.equal(true);
|
||||
|
||||
process.chdir(cwd);
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a custom renamed service in the directory if using ' +
|
||||
'the "path" and "name" option', () => {
|
||||
const cwd = process.cwd();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user