mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #3065 from vladgolubev/preserve-gitignore-on-npm-publish
Store .gitignore as gitignore in template dir. Rename on template creation
This commit is contained in:
commit
9e271999a7
@ -71,6 +71,8 @@ class Create {
|
||||
// store the custom options for the service if given
|
||||
const boilerplatePath = _.toString(this.options.path);
|
||||
const serviceName = _.toString(this.options.name);
|
||||
const templateSrcDir = path.join(this.serverless.config.serverlessPath,
|
||||
'plugins', 'create', 'templates', this.options.template);
|
||||
|
||||
// create (if not yet present) and chdir into the directory for the service
|
||||
if (boilerplatePath) {
|
||||
@ -91,9 +93,7 @@ class Create {
|
||||
process.chdir(newPath);
|
||||
} else {
|
||||
// ensure no template file already exists in cwd that we may overwrite
|
||||
const templateFullFilePaths = this.serverless.utils.walkDirSync(path.join(
|
||||
this.serverless.config.serverlessPath, 'plugins', 'create', 'templates',
|
||||
this.options.template));
|
||||
const templateFullFilePaths = this.serverless.utils.walkDirSync(templateSrcDir);
|
||||
|
||||
templateFullFilePaths.forEach(ffp => {
|
||||
const filename = path.basename(ffp);
|
||||
@ -113,8 +113,12 @@ class Create {
|
||||
// copy template files recursively to cwd
|
||||
// while keeping template file tree
|
||||
try {
|
||||
this.serverless.utils.copyDirContentsSync(path.join(this.serverless.config.serverlessPath,
|
||||
'plugins', 'create', 'templates', this.options.template), process.cwd());
|
||||
this.serverless.utils.copyDirContentsSync(templateSrcDir, process.cwd());
|
||||
|
||||
// NPM renames .gitignore to .npmignore on publish so we have to rename it.
|
||||
if (this.serverless.utils.fileExistsSync(`${process.cwd()}/gitignore`)) {
|
||||
fse.rename(`${process.cwd()}/gitignore`, `${process.cwd()}/.gitignore`);
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMessage = [
|
||||
'Error unable to create a service in this directory. ',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user