Skip to content

Commit 2f6a1bf

Browse files
nguymin4phated
authored andcommitted
New: Put all argv into the process title for better monitoring
1 parent 4917d28 commit 2f6a1bf

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var findRange = require('semver-greatest-satisfied-range');
1111
var ansi = require('./lib/shared/ansi');
1212
var exit = require('./lib/shared/exit');
1313
var tildify = require('./lib/shared/tildify');
14+
var makeTitle = require('./lib/shared/make-title');
1415
var cliOptions = require('./lib/shared/cli-options');
1516
var completion = require('./lib/shared/completion');
1617
var verifyDeps = require('./lib/shared/verify-dependencies');
@@ -35,6 +36,7 @@ process.env.INIT_CWD = process.cwd();
3536

3637
var cli = new Liftoff({
3738
name: 'gulp',
39+
processTitle: makeTitle('gulp', process.argv.slice(2)),
3840
completions: completion,
3941
extensions: interpret.jsVariants,
4042
v8flags: v8flags,

lib/shared/make-title.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
function makeTitle(cmd, argv) {
4+
if (!argv || argv.length === 0) {
5+
return cmd;
6+
}
7+
8+
return [cmd].concat(argv).join(' ');
9+
}
10+
11+
module.exports = makeTitle;

test/lib/make-title.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
var expect = require('expect');
4+
5+
var makeTitle = require('../../lib/shared/make-title');
6+
7+
describe('lib: make-title', function() {
8+
9+
it('returns the command if no argv passed', function(done) {
10+
var title = makeTitle('gulp');
11+
12+
expect(title).toEqual('gulp');
13+
done();
14+
});
15+
16+
it('returns the command if argv is 0 length', function(done) {
17+
var title = makeTitle('gulp', []);
18+
19+
expect(title).toEqual('gulp');
20+
done();
21+
});
22+
23+
it('returns the command and argvs if not empty', function(done) {
24+
var title = makeTitle('gulp', ['build']);
25+
26+
expect(title).toEqual('gulp build');
27+
done();
28+
});
29+
30+
it('concats all argv', function(done) {
31+
var title = makeTitle('gulp', ['build', '--prod']);
32+
33+
expect(title).toEqual('gulp build --prod');
34+
done();
35+
});
36+
});

0 commit comments

Comments
 (0)