Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #171 from Polymer/workaround-inquirer
Browse files Browse the repository at this point in the history
Workaround buggy window terminal prompts
  • Loading branch information
justinfagnani committed May 19, 2016
2 parents d84185a + 82a840f commit 502c5d9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

import {Command} from './command';
import {execSync} from 'child_process';
import {ArgDescriptor} from 'command-line-args';
import * as fs from 'fs';
import * as logging from 'plylog';
Expand Down Expand Up @@ -118,18 +119,32 @@ export class InitCommand implements Command {
short: name,
};
});
inquirer.prompt([{
type: 'list',
// Some windows emulators (mingw) don't handle arrows correctly
// https://github.com/SBoudrias/Inquirer.js/issues/266
// Fall back to rawlist and use number input
// Credit to https://gist.github.com/geddski/c42feb364f3c671d22b6390d82b8af8f
let isWindows = /^win/.test(process.platform);
let isMinGW = false;
if (isWindows) {
// uname might not exist if using cmd or powershell,
// which would throw an exception
try {
let uname = execSync('uname -s').toString();
isMinGW = /^mingw/i.test(uname);
} catch (e) {}
}
let prompt = {
type: isMinGW ? 'rawlist' : 'list',
name: 'generatorName',
message: 'Which starter template would you like to use?',
choices: choices,
}]).then((answers) => {
};
inquirer.prompt([prompt]).then((answers) => {
let generatorName = answers.generatorName;
runGenerator(generatorName, getDisplayName(generatorName));
});
}
});

});
}
}

0 comments on commit 502c5d9

Please sign in to comment.