Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change timing of completion to enable to configure its error message #106

Merged
merged 1 commit into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions index.js
Expand Up @@ -132,6 +132,7 @@ Liftoff.prototype.buildEnvironment = function(opts) {
return {
cwd: cwd,
preload: preload,
completion: opts.completion,
configNameSearch: configNameSearch,
configPath: configPath,
configBase: configBase,
Expand Down Expand Up @@ -164,17 +165,17 @@ Liftoff.prototype.prepare = function(opts, fn) {

process.title = this.processTitle;

var completion = opts.completion;
if (completion && this.completions) {
return this.completions(completion);
}

var env = this.buildEnvironment(opts);

fn.call(this, env);
};

Liftoff.prototype.execute = function(env, forcedFlags, fn) {
var completion = env.completion;
if (completion && this.completions) {
return this.completions(completion);
}

if (typeof forcedFlags === 'function') {
fn = forcedFlags;
forcedFlags = undefined;
Expand Down
22 changes: 12 additions & 10 deletions test/index.js
Expand Up @@ -132,16 +132,6 @@ describe('Liftoff', function() {
expect(process.title).to.equal(app.moduleName);
});

it('should return early if completions are available and requested', function(done) {
var test = new Liftoff({
name: 'whatever',
completions: function() {
done();
},
});
test.prepare({ completion: true }, function() {});
});

it('should call prepare with liftoff instance as context', function(done) {
app.prepare({}, function() {
expect(this).to.equal(app);
Expand Down Expand Up @@ -179,6 +169,18 @@ describe('Liftoff', function() {
}).to.throw();
});

it('should return early if completions are available and requested', function(done) {
var test = new Liftoff({
name: 'whatever',
completions: function() {
done();
},
});
test.prepare({ completion: true }, function(env) {
test.execute(env);
});
});

it('should skip respawning if process.argv has no values from v8flags in it', function(done) {
exec('node test/fixtures/prepare-execute/v8flags.js', function(err, stdout, stderr) {
expect(stderr).to.equal('\n');
Expand Down