Skip to content

Commit

Permalink
- support modules from parent node_modeuls
Browse files Browse the repository at this point in the history
 - bump version
  • Loading branch information
zbryikt committed Dec 16, 2022
1 parent 01ef5e1 commit 7c9b036
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 222 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Logs

## v1.1.8

- support modules from parent `node_modeuls`


## v1.1.7

- fix bug: dup installation of local module: ext modules incorrect due to local module filtering bug.
Expand Down
11 changes: 9 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cmds['default'] = {
}));
}
return (fed.modules || []).map(function(obj){
var localModule, root, info, id, mainFile, ref$, i$, name, version, ret, that, desdir, maindir, p, srcdir, realSrcdir, srcFile, desFile;
var localModule, root, base, info, id, mainFile, ref$, i$, name, version, ret, that, desdir, maindir, p, srcdir, realSrcdir, srcFile, desFile;
obj = typeof obj === 'string' ? {
name: obj
} : obj;
Expand All @@ -74,7 +74,14 @@ cmds['default'] = {
if (localModule) {
root = localModule.path;
} else {
root = path.join("node_modules", obj.name);
base = '.';
while (root !== '/') {
root = path.resolve(path.join(base, 'node_modules', obj.name));
if (fs.existsSync(root)) {
break;
}
base = path.join(base, '..');
}
}
info = JSON.parse(fs.readFileSync(path.join(root, "package.json")).toString());
id = info._id || info.name + "@" + info.version;
Expand Down
8 changes: 7 additions & 1 deletion lib/main.ls
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ cmds.default =
local-module = local-modules.filter(-> it.name == obj.name).0
if local-modules.length and !local-module => return
if local-module => root = local-module.path
else root = path.join("node_modules", obj.name)
else
base = '.'
while root != \/
root = path.resolve(path.join base, \node_modules, obj.name)
if fs.exists-sync(root) => break
base = path.join(base, \..)

info = JSON.parse(fs.read-file-sync path.join(root, "package.json") .toString!)
id = info._id or "#{info.name}@#{info.version}"

Expand Down
Loading

0 comments on commit 7c9b036

Please sign in to comment.