forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_root_finder.js
35 lines (28 loc) · 854 Bytes
/
app_root_finder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
var Fs = require("fs");
var Path = require("path");
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
var package_json = "package.json";
function find_package_json(_dir) {
while(true) {
var dir = _dir;
if (Fs.existsSync(Path.join(dir, package_json))) {
return dir;
} else {
var new_dir = Path.dirname(dir);
if (new_dir === dir) {
throw Caml_builtin_exceptions.not_found;
} else {
_dir = new_dir;
continue ;
}
}
};
}
var match = typeof (__dirname) === "undefined" ? undefined : (__dirname);
if (match !== undefined) {
console.log(find_package_json(match));
}
exports.package_json = package_json;
exports.find_package_json = find_package_json;
/* match Not a pure module */