Skip to content

Commit 3f80103

Browse files
committed
enhancement(start): change start task to default to typescript if project is started as v2.
1 parent 3505ce8 commit 3f80103

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/ionic/start.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ function run(ionic, argv) {
6262
return templateUtils.listTemplates();
6363
}
6464

65+
// If we are starting a version 2 project then typescript should be set by default
66+
if ((argv.v2 || argv.v) && !argv.ts && !argv.typescript) {
67+
argv.ts = true;
68+
}
69+
6570
if (argv._.length < 2) {
6671
return appLibUtils.fail('Invalid command', 'start');
6772
}

spec/tasks/start.spec.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,30 @@ describe('start command', function() {
133133
done();
134134
});
135135
});
136-
it('should provide extra content if starting a v2 project', function(done) {
136+
137+
it('should default to typescript if starting a v2 project with -v', function(done) {
138+
var processArguments = ['node', 'ionic', 'start', 'newDir', '-v'];
139+
var rawCliArguments = processArguments.slice(2);
140+
var argv = optimist(rawCliArguments).argv;
141+
142+
spyOn(fs, 'existsSync').andReturn(false);
143+
spyOn(appLibUtils, 'preprocessCliOptions').andCallThrough();
144+
spyOn(Start, 'promptForOverwrite');
145+
spyOn(Start, 'startApp').andReturn(Q(true));
146+
spyOn(Start, 'printQuickHelp').andReturn(Q(true));
147+
spyOn(Start, 'promptLogin').andReturn(Q(true));
148+
149+
start.run({}, argv).then(function() {
150+
expect(appLibUtils.preprocessCliOptions.calls[0].args[0].v).toEqual(true);
151+
expect(appLibUtils.preprocessCliOptions.calls[0].args[0].ts).toEqual(true);
152+
expect(log.info).toHaveBeenCalledWith(
153+
'\nNew to Ionic? Get started here: http://ionicframework.com/docs/v2/getting-started\n'
154+
);
155+
done();
156+
});
157+
});
158+
159+
it('should default to typescript if starting a v2 project with --v2', function(done) {
137160
var processArguments = ['node', 'ionic', 'start', 'newDir', '--v2'];
138161
var rawCliArguments = processArguments.slice(2);
139162
var argv = optimist(rawCliArguments).argv;
@@ -146,6 +169,8 @@ describe('start command', function() {
146169
spyOn(Start, 'promptLogin').andReturn(Q(true));
147170

148171
start.run({}, argv).then(function() {
172+
expect(appLibUtils.preprocessCliOptions.calls[0].args[0].v2).toEqual(true);
173+
expect(appLibUtils.preprocessCliOptions.calls[0].args[0].ts).toEqual(true);
149174
expect(log.info).toHaveBeenCalledWith(
150175
'\nNew to Ionic? Get started here: http://ionicframework.com/docs/v2/getting-started\n'
151176
);

0 commit comments

Comments
 (0)