This repository was archived by the owner on Dec 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 99 */
1010
1111import { Command } from './command' ;
12+ import { execSync } from 'child_process' ;
1213import { ArgDescriptor } from 'command-line-args' ;
1314import * as fs from 'fs' ;
1415import * as logging from 'plylog' ;
@@ -118,18 +119,32 @@ export class InitCommand implements Command {
118119 short : name ,
119120 } ;
120121 } ) ;
121- inquirer . prompt ( [ {
122- type : 'list' ,
122+ // Some windows emulators (mingw) don't handle arrows correctly
123+ // https://github.com/SBoudrias/Inquirer.js/issues/266
124+ // Fall back to rawlist and use number input
125+ // Credit to https://gist.github.com/geddski/c42feb364f3c671d22b6390d82b8af8f
126+ let isWindows = / ^ w i n / . test ( process . platform ) ;
127+ let isMinGW = false ;
128+ if ( isWindows ) {
129+ // uname might not exist if using cmd or powershell,
130+ // which would throw an exception
131+ try {
132+ let uname = execSync ( 'uname -s' ) . toString ( ) ;
133+ isMinGW = / ^ m i n g w / i. test ( uname ) ;
134+ } catch ( e ) { }
135+ }
136+ let prompt = {
137+ type : isMinGW ? 'rawlist' : 'list' ,
123138 name : 'generatorName' ,
124139 message : 'Which starter template would you like to use?' ,
125140 choices : choices ,
126- } ] ) . then ( ( answers ) => {
141+ } ;
142+ inquirer . prompt ( [ prompt ] ) . then ( ( answers ) => {
127143 let generatorName = answers . generatorName ;
128144 runGenerator ( generatorName , getDisplayName ( generatorName ) ) ;
129145 } ) ;
130146 }
131147 } ) ;
132-
133148 } ) ;
134149 }
135150}
You can’t perform that action at this time.
0 commit comments