Skip to content

Commit

Permalink
fix(cli): avoid npm gitignore rename on new plugins (#3292)
Browse files Browse the repository at this point in the history
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
  • Loading branch information
imhoffd and jcesarmobile authored Jul 20, 2020
1 parent 890f349 commit 2c9b5e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ export function getNpmClient(config: Config, npmClient: string): Promise<string>

export async function copyTemplate(src: string, dst: string) {
await copyAsync(src, dst);
await renameGitignore(dst);
}

export async function renameGitignore(dst: string) {
// npm renames .gitignore to something else, so our templates
// have .gitignore as gitignore, we need to rename it here.
const gitignorePath = join(dst, 'gitignore');
Expand Down
3 changes: 2 additions & 1 deletion cli/src/tasks/new-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config } from '../config';
import { log, logFatal, logInfo, logWarn, runCommand, runTask, writePrettyJSON } from '../common';
import { log, logFatal, logInfo, logWarn, renameGitignore, runCommand, runTask, writePrettyJSON } from '../common';
import { OS } from '../definitions';
import { emoji } from '../util/emoji';
import { existsAsync, mkdirAsync, readFileAsync, writeFileAsync } from '../util/fs';
Expand Down Expand Up @@ -107,6 +107,7 @@ export async function newPlugin(config: Config) {

await runTask('Adding plugin files', async () => {
await copy(config.plugins.assets.templateDir, pluginPath);
await renameGitignore(pluginPath);
await createTSPlugin(config, pluginPath, domain, className, answers);
await createIosPlugin(config, pluginPath, domain, className, answers);
await createAndroidPlugin(config, pluginPath, domain, className);
Expand Down
4 changes: 4 additions & 0 deletions plugin-template/.gitignore → plugin-template/gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NPM renames .gitignore to .npmignore
# In order to prevent that, we remove the initial "."
# And the CLI then renames it

# node files
dist/
node_modules/
Expand Down

0 comments on commit 2c9b5e1

Please sign in to comment.