repl: allow autocompletion for scoped packages
Previously, autocompletion of scoped packages was not supported by the repl due to not including the `@` character in the regular expression. PR-URL: https://github.com/nodejs/node/pull/10296 Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5acfbb0f25
commit
e248f7f9e7
@ -787,7 +787,7 @@ ArrayStream.prototype.writable = true;
|
||||
ArrayStream.prototype.resume = function() {};
|
||||
ArrayStream.prototype.write = function() {};
|
||||
|
||||
const requireRE = /\brequire\s*\(['"](([\w./-]+\/)?([\w./-]*))/;
|
||||
const requireRE = /\brequire\s*\(['"](([\w@./-]+\/)?([\w@./-]*))/;
|
||||
const simpleExpressionRE =
|
||||
/(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/;
|
||||
|
||||
|
1
test/fixtures/node_modules/@nodejsscope/index.js
generated
vendored
Normal file
1
test/fixtures/node_modules/@nodejsscope/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
// Not used
|
@ -1,8 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var repl = require('repl');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// We have to change the directory to ../fixtures before requiring repl
|
||||
// in order to make the tests for completion of node_modules work properly
|
||||
// since repl modifies module.paths.
|
||||
process.chdir(common.fixturesDir);
|
||||
|
||||
const repl = require('repl');
|
||||
|
||||
function getNoResultsFunction() {
|
||||
return common.mustCall((err, data) => {
|
||||
@ -196,6 +202,15 @@ testMe.complete('require(\'n', common.mustCall(function(error, data) {
|
||||
});
|
||||
}));
|
||||
|
||||
{
|
||||
const expected = ['@nodejsscope', '@nodejsscope/'];
|
||||
putIn.run(['.clear']);
|
||||
testMe.complete('require(\'@nodejs', common.mustCall((err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
assert.deepStrictEqual(data, [expected, '@nodejs']);
|
||||
}));
|
||||
}
|
||||
|
||||
// Make sure tab completion works on context properties
|
||||
putIn.run(['.clear']);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user