11'use strict' ;
22
33const path = require ( 'path' ) ;
4+ const fs = require ( 'fs-extra' ) ;
45const utils = require ( './utils' ) ;
56
7+ const nodeModulesIgnore = `
8+
9+ /node_modules/
10+ ` ;
11+
612module . exports = function getStartAndEndCommands ( {
713 packageJson : { name : projectName } ,
814 projectOptions,
@@ -80,16 +86,18 @@ function createProjectFromRemote(command) {
8086 options
8187 } ) {
8288 return async function createProject ( cwd ) {
83- let npxCommand ;
8489 if ( options . blueprint . name !== 'ember-cli' ) {
85- npxCommand = `ember-cli ${ command } -b ${ options . blueprint . path } ` ;
86- // npxCommand = `-p github:ember-cli/ember-cli#cfb9780 ember ${command} -b ${options.blueprint.name}@${options.packageVersion}`;
90+ await utils . npx ( `ember-cli ${ command } -b ${ options . blueprint . path } ` , { cwd } ) ;
91+ // await utils.npx(`-p github:ember-cli/ember-cli#cfb9780 ember ${command} -b ${options.blueprint.name}@${options.packageVersion}`, { cwd });
92+
93+ await module . exports . appendNodeModulesIgnore ( {
94+ cwd,
95+ projectName : options . projectName
96+ } ) ;
8797 } else {
88- npxCommand = `-p ember-cli@${ options . packageVersion } ember ${ command } ` ;
98+ await utils . npx ( `-p ember-cli@${ options . packageVersion } ember ${ command } ` , { cwd } ) ;
8999 }
90100
91- await utils . npx ( npxCommand , { cwd } ) ;
92-
93101 return postCreateProject ( {
94102 cwd,
95103 options
@@ -106,3 +114,21 @@ function postCreateProject({
106114} ) {
107115 return path . join ( cwd , projectName ) ;
108116}
117+
118+ async function appendNodeModulesIgnore ( {
119+ cwd,
120+ projectName
121+ } ) {
122+ let isIgnoringNodeModules ;
123+ let gitignore = '' ;
124+ try {
125+ gitignore = await fs . readFile ( path . join ( cwd , projectName , '.gitignore' ) , 'utf8' ) ;
126+
127+ isIgnoringNodeModules = / ^ \/ ? n o d e _ m o d u l e s \/ ? $ / m. test ( gitignore ) ;
128+ } catch ( err ) { }
129+ if ( ! isIgnoringNodeModules ) {
130+ await fs . writeFile ( path . join ( cwd , projectName , '.gitignore' ) , `${ gitignore } ${ nodeModulesIgnore } ` ) ;
131+ }
132+ }
133+
134+ module . exports . appendNodeModulesIgnore = appendNodeModulesIgnore ;
0 commit comments