Skip to content

Commit

Permalink
New: Put all argv into the process title for better monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nguymin4 authored and phated committed Dec 21, 2017
1 parent 4917d28 commit 2f6a1bf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var findRange = require('semver-greatest-satisfied-range');
var ansi = require('./lib/shared/ansi');
var exit = require('./lib/shared/exit');
var tildify = require('./lib/shared/tildify');
var makeTitle = require('./lib/shared/make-title');
var cliOptions = require('./lib/shared/cli-options');
var completion = require('./lib/shared/completion');
var verifyDeps = require('./lib/shared/verify-dependencies');
Expand All @@ -35,6 +36,7 @@ process.env.INIT_CWD = process.cwd();

var cli = new Liftoff({
name: 'gulp',
processTitle: makeTitle('gulp', process.argv.slice(2)),
completions: completion,
extensions: interpret.jsVariants,
v8flags: v8flags,
Expand Down
11 changes: 11 additions & 0 deletions lib/shared/make-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

function makeTitle(cmd, argv) {
if (!argv || argv.length === 0) {
return cmd;
}

return [cmd].concat(argv).join(' ');
}

module.exports = makeTitle;
36 changes: 36 additions & 0 deletions test/lib/make-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var expect = require('expect');

var makeTitle = require('../../lib/shared/make-title');

describe('lib: make-title', function() {

it('returns the command if no argv passed', function(done) {
var title = makeTitle('gulp');

expect(title).toEqual('gulp');
done();
});

it('returns the command if argv is 0 length', function(done) {
var title = makeTitle('gulp', []);

expect(title).toEqual('gulp');
done();
});

it('returns the command and argvs if not empty', function(done) {
var title = makeTitle('gulp', ['build']);

expect(title).toEqual('gulp build');
done();
});

it('concats all argv', function(done) {
var title = makeTitle('gulp', ['build', '--prod']);

expect(title).toEqual('gulp build --prod');
done();
});
});

0 comments on commit 2f6a1bf

Please sign in to comment.