Skip to content

Commit

Permalink
sync fork
Browse files Browse the repository at this point in the history
  • Loading branch information
benholloway committed Jan 27, 2015
2 parents 1738fbe + ab32d81 commit 17de724
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
18 changes: 18 additions & 0 deletions bin/cli-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var yargs = require('yargs');
var config = require('../lib/config/config');

var args = yargs
.describe('p', 'Define a port number when serving files')
.alias('p', 'port')
.default('p', config.getServerHttpPort())
.describe('v', 'Display version number')
.alias('v', 'version')
.boolean('v')
.describe('n', 'Name of the project to create or work on')
.alias('n', 'name')
.string('n')
.usage('Angularity is an opinionated build tool for AngularJs projects.')
.wrap(config.getConsoleWidth());
module.exports = args;
43 changes: 16 additions & 27 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var path = require('path'),
prettyTime = require('pretty-hrtime');

var mainMenu = require('../lib/cli/mainMenu');

require('../index');

var generator = require('../lib/generator/generator');
Expand All @@ -33,29 +32,19 @@ gulp.on('task_stop', function (e) {
);
});

// expect the second argument to be the task name
var taskName = process.argv[2];
switch(taskName) {

// with no arguments, prompt the main menu.
case undefined:
mainMenu.prompt();
break;

// allow a version command with `angularity -v`
case 'v':
case '-v':
var packagePath = path.join(__dirname, '..', 'package.json');
var version = require(packagePath).version;
console.log('angularity:', version);
break;

// use the project generator with `angularity generate <name>`
case 'generate':
generator.util.generateProject(process.argv[3]);
break;

// allow the default gulp tasks to be run on the global cli
default:
gulp.start(gulp.hasTask(taskName) ? taskName : 'default');
}
// gulp tasks can access argv using this same method
var argv = require('./cli-args').argv;

var taskName = (!!argv._) ? argv._[0] : undefined;

if (argv.version) {
var packagePath = path.join(__dirname, '..', 'package.json');
var version = require(packagePath).version;
console.log('angularity:', version);
}
else if (!taskName) {
mainMenu.prompt();
}
else {
gulp.start(gulp.hasTask(taskName) ? taskName : 'default');
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"bower-directory": "latest",
"browser-sync": "latest",
"browserify": "latest",
"browserify-ngannotate": "latest",
"browserify-transform-tools": "latest",
"chalk": "latest",
"combined-stream": "latest",
Expand Down Expand Up @@ -69,13 +70,12 @@
"lodash.defaults": "latest",
"lodash.flatten": "latest",
"lodash.merge": "latest",
"lodash.template": "latest",
"lodash.reduce": "latest",
"lodash.template": "latest",
"mime": "latest",
"minifyify": "latest",
"minimatch": "latest",
"mold-source-map": "latest",
"browserify-ngannotate": "latest",
"node-bourbon": "latest",
"node-sass": "latest",
"pretty-hrtime": "latest",
Expand All @@ -90,7 +90,8 @@
"stream-spigot": "latest",
"stringify": "latest",
"through-pipes": "latest",
"through2": "latest"
"through2": "latest",
"yargs": "latest"
},
"devDependencies": {
"jasmine-node": "latest",
Expand Down
9 changes: 9 additions & 0 deletions tasks/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var gulp = require('gulp');
var argv = require('../bin/cli-args').argv;
var generator = require('../lib/generator/generator');

gulp.task('generate', [], function() {
generator.util.generateProject(argv.name);
});
6 changes: 4 additions & 2 deletions tasks/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var config = require('../lib/config/config'),
hr = require('../lib/util/hr'),
streams = require('../lib/config/streams');

var HTTP_PORT = config.getServerHttpPort();
var argv = require('../bin/cli-args').argv;

var HTTP_PORT = argv.port;
var CONSOLE_WIDTH = config.getConsoleWidth();

gulp.task('server', ['build'], function () {
Expand All @@ -29,4 +31,4 @@ gulp.task('reload', function () {
console.log(hr('-', CONSOLE_WIDTH, 'reload'));
gutil.log('serving on port:', HTTP_PORT);
browserSync.reload();
});
});
3 changes: 1 addition & 2 deletions tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var config = require('../lib/config/config'),
var CONSOLE_WIDTH = config.getConsoleWidth();

gulp.task('watch', ['server'], function () {

// enqueue actions to avoid multiple trigger
var queue = watchSequence(500, function () {
console.log(hr('\u2591', CONSOLE_WIDTH));
Expand All @@ -37,4 +36,4 @@ gulp.task('watch', ['server'], function () {
name : 'TEST',
emitOnGlob: false
}, queue.getHandler('test'));
});
});

0 comments on commit 17de724

Please sign in to comment.