Skip to content

Commit

Permalink
fix(ionic): Run ionic and watch concurrently. Closes #114, #116, & #121
Browse files Browse the repository at this point in the history
  • Loading branch information
diegonetto committed Oct 24, 2014
1 parent 0ceed24 commit 1f301ba
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ module.exports = function (grunt) {
},

concurrent: {
ionic: {
tasks: [],
options: {
logConcurrentOutput: true
}
},
server: [<% if (compass) { %>
'compass:server',<% } %>
'copy:styles',
Expand Down Expand Up @@ -478,21 +484,14 @@ module.exports = function (grunt) {

// Wrap ionic-cli commands
grunt.registerTask('ionic', function() {
var done = this.async();
var script = path.resolve('./node_modules/ionic/bin/', 'ionic');
var flags = process.argv.splice(3);
var child = spawn(script, this.args.concat(flags));
child.stdout.on('data', function (data) {
grunt.log.writeln(data);
});
child.stderr.on('data', function (data) {
grunt.log.error(data);
var child = spawn(script, this.args.concat(flags), { stdio: 'inherit' });
child.on('close', function (code) {
code = code ? false : true;
done(code);
});
process.on('exit', function (code) {
child.kill('SIGINT');
process.exit(code);
});

return grunt.task.run(['watch']);
});

grunt.registerTask('test', [
Expand All @@ -502,18 +501,22 @@ module.exports = function (grunt) {
'karma:unit:start',
'watch:karma'
]);

grunt.registerTask('serve', function (target) {
if (target === 'compress') {
return grunt.task.run(['compress', 'ionic:serve']);
}

grunt.task.run(['init', 'ionic:serve']);
grunt.config('concurrent.ionic.tasks', ['ionic:serve', 'watch']);
grunt.task.run(['init', 'concurrent:ionic']);
});
grunt.registerTask('emulate', function() {
return grunt.task.run(['init', 'ionic:emulate:' + this.args.join()]);
grunt.config('concurrent.ionic.tasks', ['ionic:emulate:' + this.args.join(), 'watch']);
return grunt.task.run(['init', 'concurrent:ionic']);
});
grunt.registerTask('run', function() {
return grunt.task.run(['init', 'ionic:run:' + this.args.join()]);
grunt.config('concurrent.ionic.tasks', ['ionic:run:' + this.args.join(), 'watch']);
return grunt.task.run(['init', 'concurrent:ionic']);
});
grunt.registerTask('build', function() {
return grunt.task.run(['init', 'ionic:build:' + this.args.join()]);
Expand Down

0 comments on commit 1f301ba

Please sign in to comment.