Skip to content

Commit 06deca9

Browse files
committed
return several ignore objects
1 parent 602b267 commit 06deca9

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

lib/Resolver.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,16 @@ class Resolver {
274274
};
275275

276276
let yield_;
277-
let ignoredObj;
277+
let yieldCalled = false;
278278
let finishYield;
279-
let yieldCalled = 0;
280279
if (typeof resolveContext.yield === "function") {
281280
const old = resolveContext.yield;
282281
yield_ = obj => {
283-
if (obj.path === false) {
284-
if (ignoredObj) return;
285-
ignoredObj = obj;
286-
} else {
287-
old(obj);
288-
}
289-
yieldCalled++;
282+
old(obj);
283+
yieldCalled = true;
290284
};
291285
finishYield = result => {
292286
if (result) yield_(result);
293-
if (yieldCalled === 1 && ignoredObj) old(ignoredObj);
294287
callback(null);
295288
};
296289
}

test/yield.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const CachedInputFileSystem = require("../lib/CachedInputFileSystem");
1010

1111
const nodeFileSystem = new CachedInputFileSystem(fs, 4000);
1212
const fixtures = path.resolve(__dirname, "fixtures", "yield");
13-
const makeFixturePaths = paths => paths.map(pth => path.join(fixtures, pth));
13+
const makeFixturePaths = paths =>
14+
paths.map(pth => (pth ? path.join(fixtures, pth) : pth));
1415
const contextifyDependencies = paths =>
1516
Array.from(paths)
1617
.filter(pth => pth.startsWith(fixtures))
@@ -321,27 +322,35 @@ describe("should resolve all aliases", () => {
321322

322323
it("default order", done => {
323324
resolver = createResolver(["/c/foo", "/a/foo"]);
324-
run(done, [
325-
"resolve 'index/a' in 'fixtures'",
326-
" Parsed request is a module",
327-
" using description file (relative path: ./test/fixtures/yield)",
328-
...cLog,
329-
...aLog
330-
]);
325+
run(
326+
done,
327+
[false, "/a/foo/a"],
328+
[
329+
"resolve 'index/a' in 'fixtures'",
330+
" Parsed request is a module",
331+
" using description file (relative path: ./test/fixtures/yield)",
332+
...cLog,
333+
...aLog
334+
]
335+
);
331336
});
332337

333338
it("reverse order", done => {
334339
resolver = createResolver(["/a/foo", "/c/foo"]);
335-
run(done, [
336-
"resolve 'index/a' in 'fixtures'",
337-
" Parsed request is a module",
338-
" using description file (relative path: ./test/fixtures/yield)",
339-
...aLog,
340-
...cLog
341-
]);
340+
run(
341+
done,
342+
["/a/foo/a", false],
343+
[
344+
"resolve 'index/a' in 'fixtures'",
345+
" Parsed request is a module",
346+
" using description file (relative path: ./test/fixtures/yield)",
347+
...aLog,
348+
...cLog
349+
]
350+
);
342351
});
343352

344-
function run(done, expectedLogs) {
353+
function run(done, expectedResult, expectedLogs) {
345354
let calls = 0;
346355
const paths = [];
347356
const logs = [];
@@ -363,7 +372,7 @@ describe("should resolve all aliases", () => {
363372
should(calls).be.eql(1);
364373
should(err).be.eql(null);
365374
should(result).be.eql(undefined);
366-
should(paths).be.eql(makeFixturePaths(["/a/foo/a"]));
375+
should(paths).be.eql(makeFixturePaths(expectedResult));
367376
should(contextifyDependencies(fileDependencies)).be.eql([
368377
"",
369378
"/a",

0 commit comments

Comments
 (0)