Skip to content

Commit 5fd991a

Browse files
committed
avoid duplicate
1 parent 2d5508a commit 5fd991a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/core/src/file.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function check(name) {
1212
try {
1313
return req.resolve(name);
1414
} catch (e) {
15+
debug('ezs:warn')(`req.resolve failed with '${name}'`);
1516
return null;
1617
}
1718
}
@@ -31,6 +32,7 @@ export function useFile(ezs, name) {
3132
'ezs-'.concat(String(name).replace(/^ezs-/, '')),
3233
'@ezs/'.concat(String(bname).replace(/^@ezs\//, '')),
3334
'ezs-'.concat(String(bname).replace(/^ezs-/, '')),
35+
String(bname).concat('/src/'),
3436
];
3537
const plugName1 = names.map((n) => check(n)).filter(Boolean).shift();
3638
const plugName2 = names.map((n) => findFileIn(ezs.getPath(), n)).filter(Boolean).shift();

packages/core/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PassThrough } from 'readable-stream';
22
import debug from 'debug';
3+
import uniq from 'lodash/uniq';
34
import writeTo from 'stream-write';
45
import LRU from 'lru-cache';
56
import Engine from './engine.js';
@@ -76,7 +77,7 @@ ezs.useFiles = (files) => {
7677
return Statement.list();
7778
};
7879
ezs.addPath = (p) => ezs.settings.pluginPaths.push(p);
79-
ezs.getPath = () => ezs.settings.pluginPaths;
80+
ezs.getPath = () => uniq(ezs.settings.pluginPaths);
8081
ezs.getCache = () => ezsCache;
8182
ezs.loadScript = (file) => File(ezs, file);
8283
ezs.compileScript = (script) => new Commands(ezs.parseString(script));

packages/core/src/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const continueDelay = Number(process.env.EZS_CONTINUE_DELAY || 5);
1818
const pipelineDelay = Number(process.env.EZS_PIPELINE_DELAY || 300);
1919
const [, dirname] = filedirname();
2020
const pluginPaths = [
21-
resolve(dirname, '../..'),
22-
resolve(dirname, '../../node_modules'),
23-
process.cwd(),
21+
resolve(dirname, '../..'),
22+
resolve(dirname, '../../node_modules'),
23+
process.cwd(),
2424
resolve(process.cwd(), './node_modules'),
2525
globalModules
2626
];

0 commit comments

Comments
 (0)