Skip to content

Commit a51fd6a

Browse files
author
Kelly Selden
committed
extract inquirer operations
1 parent dd58c5d commit a51fd6a

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/overwrite-blueprint-files.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const blueprintOverwriteRegex = /^\? Overwrite (.+)\? /m;
44

5+
const yes = 'y';
6+
const enter = '\n';
7+
58
function overwriteBlueprintFiles(ps) {
69
let existingMatches = [];
710

@@ -17,8 +20,6 @@ function overwriteBlueprintFiles(ps) {
1720

1821
let matches = str.match(blueprintOverwriteRegex);
1922
if (matches) {
20-
let yes = 'y';
21-
let enter = '\n';
2223
ps.stdin.write(`${yes}${enter}`);
2324

2425
existingMatches.push(matches[1]);

test/acceptance/ember-cli-update-test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const overwriteBlueprintFiles = require('../../src/overwrite-blueprint-files');
2424

2525
const toDefault = require('../../src/args').to.default;
2626

27+
const select = ' ';
28+
const down = '\u001b[B';
29+
const enter = '\n';
30+
2731
describe(function() {
2832
this.timeout(30 * 1000);
2933

@@ -187,7 +191,7 @@ describe(function() {
187191
function stdoutData(data) {
188192
let str = data.toString();
189193
if (str.includes('These codemods apply to your project.')) {
190-
ps.stdin.write(' \n');
194+
ps.stdin.write(`${select}${enter}`);
191195
ps.stdout.removeListener('data', stdoutData);
192196
resolve();
193197
}
@@ -298,8 +302,6 @@ describe(function() {
298302
function whichBlueprint(data) {
299303
let str = data.toString();
300304
if (str.includes('Blueprint updates have been found.')) {
301-
let down = '\u001b[B';
302-
let enter = '\n';
303305
ps.stdin.write(`${down}${enter}`);
304306
ps.stdout.removeListener('data', whichBlueprint);
305307
resolve();
@@ -311,8 +313,6 @@ describe(function() {
311313
function whichVersion(data) {
312314
let str = data.toString();
313315
if (str.includes('Do you want the latest version?')) {
314-
let down = '\u001b[B';
315-
let enter = '\n';
316316
ps.stdin.write(`${down}${enter}`);
317317
ps.stdout.removeListener('data', whichVersion);
318318
resolve();
@@ -325,7 +325,6 @@ describe(function() {
325325
let str = data.toString();
326326
if (str.includes('What version?')) {
327327
let range = to;
328-
let enter = '\n';
329328
ps.stdin.write(`${range}${enter}`);
330329
ps.stdout.removeListener('data', customVersion);
331330
resolve();
@@ -377,8 +376,6 @@ describe(function() {
377376
function whichBlueprint(data) {
378377
let str = data.toString();
379378
if (str.includes('Which blueprint would you like to reset?')) {
380-
let down = '\u001b[B';
381-
let enter = '\n';
382379
ps.stdin.write(`${down}${enter}`);
383380
ps.stdout.removeListener('data', whichBlueprint);
384381
resolve();

0 commit comments

Comments
 (0)