Skip to content

Commit 30f246d

Browse files
committed
removed findup-sync dependency
1 parent 2945722 commit 30f246d

File tree

3 files changed

+26
-125
lines changed

3 files changed

+26
-125
lines changed

bin/build.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
let url = require('url');
22
let compile = require('./compile');
33
let path = require('path');
4-
let findNodeModules = require('findup-sync');
54
let fs = require('fs');
65
let util = require('util');
76
let writeFile = util.promisify(fs.writeFile);
@@ -30,7 +29,7 @@ async function runSingle(schemaTs) {
3029
}
3130
console.log(`Orange: found schema ${schemaTs}`);
3231
if (!schemaJsPath) {
33-
let nodeModules = findNodeModules('node_modules', { cwd: schemaTs });
32+
let nodeModules = findClosestNodeModules(schemaTs);
3433
outDir = path.join(nodeModules, '/.rdb', '/' + new Date().getUTCMilliseconds());
3534
schemaJsPath = compile(schemaTs, { outDir });
3635
}
@@ -112,6 +111,21 @@ function findClosestPackageJson(startDir) {
112111
return null;
113112
}
114113

114+
function findClosestNodeModules(startPath) {
115+
const startDir = fs.statSync(startPath).isDirectory() ? startPath : path.dirname(startPath);
116+
let currentDir = startDir;
117+
while (true) {
118+
const nodeModulesPath = path.join(currentDir, 'node_modules');
119+
if (fs.existsSync(nodeModulesPath))
120+
return nodeModulesPath;
121+
122+
const parentDir = path.dirname(currentDir);
123+
if (parentDir === currentDir)
124+
return path.join(startDir, 'node_modules');
125+
currentDir = parentDir;
126+
}
127+
}
128+
115129
async function findSchemaJs(cwd) {
116130
let ignoredDirNames = {
117131
node_modules: true,

package-lock.json

Lines changed: 10 additions & 122 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"ajv": "^8.17.1",
8181
"axios": "^1.6.2",
8282
"fast-json-patch": "^3.1.1",
83-
"findup-sync": "^5.0.0",
8483
"rfdc": "^1.2.0",
8584
"uuid": "^8.3.2 || ^9.0.0 || ^10.0.0 || ^11.1.0"
8685
},

0 commit comments

Comments
 (0)