You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

module-root-sync

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-root-sync - npm Package Compare versions

Comparing version
1.1.10
to
1.1.11
+3
dist/cjs/index.d.ts
import type { RootOptions } from './types.js';
export * from './types.js';
export default function moduleRoot(dir: string, options?: RootOptions): string;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return moduleRoot;
}
});
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
_export_star(require("./types.js"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
return from;
}
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var existsSync = function(test) {
try {
(_fs.default.accessSync || _fs.default.statSync)(test);
return true;
} catch (_) {
return false;
}
};
function moduleRoot(dir) {
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var current = dir;
do {
var packagePath = _path.default.join(current, 'package.json');
if (existsSync(packagePath)) {
if (!options.keyExists) return current;
if (JSON.parse(_fs.default.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;
}
var next = _path.default.dirname(current);
if (next === current) break;
current = next;
}while (current);
throw new Error('Root not found');
}
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\nimport type { RootOptions } from './types.js';\nexport * from './types.js';\nexport default function moduleRoot(dir: string, options: RootOptions = {}) {\n let current = dir;\n do {\n const packagePath = path.join(current, 'package.json');\n if (existsSync(packagePath)) {\n if (!options.keyExists) return current;\n if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;\n }\n const next = path.dirname(current);\n if (next === current) break;\n current = next;\n } while (current);\n throw new Error('Root not found');\n}\n"],"names":["moduleRoot","existsSync","test","fs","accessSync","statSync","_","dir","options","current","packagePath","path","join","keyExists","JSON","parse","readFileSync","undefined","next","dirname","Error"],"mappings":";;;;+BAYA;;;eAAwBA;;;yDAZT;2DACE;qBAUH;;;;;;;;;;;;;;;;;;;AATd,IAAMC,aAAa,SAACC;IAClB,IAAI;QACDC,CAAAA,WAAE,CAACC,UAAU,IAAID,WAAE,CAACE,QAAQ,AAAD,EAAGH;QAC/B,OAAO;IACT,EAAE,OAAOI,GAAG;QACV,OAAO;IACT;AACF;AAGe,SAASN,WAAWO,GAAW;QAAEC,UAAAA,iEAAuB,CAAC;IACtE,IAAIC,UAAUF;IACd,GAAG;QACD,IAAMG,cAAcC,aAAI,CAACC,IAAI,CAACH,SAAS;QACvC,IAAIR,WAAWS,cAAc;YAC3B,IAAI,CAACF,QAAQK,SAAS,EAAE,OAAOJ;YAC/B,IAAIK,KAAKC,KAAK,CAACZ,WAAE,CAACa,YAAY,CAACN,aAAa,QAAQ,CAACF,QAAQK,SAAS,CAAC,KAAKI,WAAW,OAAOR;QAChG;QACA,IAAMS,OAAOP,aAAI,CAACQ,OAAO,CAACV;QAC1B,IAAIS,SAAST,SAAS;QACtBA,UAAUS;IACZ,QAAST,SAAS;IAClB,MAAM,IAAIW,MAAM;AAClB"}
{ "type": "commonjs" }
export interface RootOptions {
keyExists?: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
{"version":3,"sources":[],"names":[],"mappings":""}
import type { RootOptions } from './types.js';
export * from './types.js';
export default function moduleRoot(dir: string, options?: RootOptions): string;
import fs from 'fs';
import path from 'path';
const existsSync = (test)=>{
try {
(fs.accessSync || fs.statSync)(test);
return true;
} catch (_) {
return false;
}
};
export * from './types.js';
export default function moduleRoot(dir, options = {}) {
let current = dir;
do {
const packagePath = path.join(current, 'package.json');
if (existsSync(packagePath)) {
if (!options.keyExists) return current;
if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;
}
const next = path.dirname(current);
if (next === current) break;
current = next;
}while (current)
throw new Error('Root not found');
}
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\nimport type { RootOptions } from './types.js';\nexport * from './types.js';\nexport default function moduleRoot(dir: string, options: RootOptions = {}) {\n let current = dir;\n do {\n const packagePath = path.join(current, 'package.json');\n if (existsSync(packagePath)) {\n if (!options.keyExists) return current;\n if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;\n }\n const next = path.dirname(current);\n if (next === current) break;\n current = next;\n } while (current);\n throw new Error('Root not found');\n}\n"],"names":["fs","path","existsSync","test","accessSync","statSync","_","moduleRoot","dir","options","current","packagePath","join","keyExists","JSON","parse","readFileSync","undefined","next","dirname","Error"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,MAAMC,aAAa,CAACC;IAClB,IAAI;QACDH,CAAAA,GAAGI,UAAU,IAAIJ,GAAGK,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,cAAc,aAAa;AAC3B,eAAe,SAASC,WAAWC,GAAW,EAAEC,UAAuB,CAAC,CAAC;IACvE,IAAIC,UAAUF;IACd,GAAG;QACD,MAAMG,cAAcV,KAAKW,IAAI,CAACF,SAAS;QACvC,IAAIR,WAAWS,cAAc;YAC3B,IAAI,CAACF,QAAQI,SAAS,EAAE,OAAOH;YAC/B,IAAII,KAAKC,KAAK,CAACf,GAAGgB,YAAY,CAACL,aAAa,QAAQ,CAACF,QAAQI,SAAS,CAAC,KAAKI,WAAW,OAAOP;QAChG;QACA,MAAMQ,OAAOjB,KAAKkB,OAAO,CAACT;QAC1B,IAAIQ,SAASR,SAAS;QACtBA,UAAUQ;IACZ,QAASR,QAAS;IAClB,MAAM,IAAIU,MAAM;AAClB"}
{ "type": "module" }
export interface RootOptions {
keyExists?: string;
}
export { };
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/types.ts"],"sourcesContent":["export interface RootOptions {\n keyExists?: string;\n}\n"],"names":[],"mappings":"AAAA,WAEC"}
+2
-2

@@ -1,3 +0,3 @@

import type { RootOptions } from './types';
export * from './types';
import type { RootOptions } from './types.js';
export * from './types.js';
export default function moduleRoot(dir: string, options?: RootOptions): string;
{
"name": "module-root-sync",
"version": "1.1.10",
"version": "1.1.11",
"description": "Finds the directory that the modules resides in",

@@ -27,8 +27,8 @@ "keywords": [

".": {
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.cjs"
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"main": "dist/cjs/index.cjs",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.cts",

@@ -35,0 +35,0 @@ "files": [

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return moduleRoot;
}
});
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
_export_star(require("./types.cjs"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
return from;
}
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var existsSync = function(test) {
try {
(_fs.default.accessSync || _fs.default.statSync)(test);
return true;
} catch (_) {
return false;
}
};
function moduleRoot(dir) {
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var current = dir;
do {
var packagePath = _path.default.join(current, 'package.json');
if (existsSync(packagePath)) {
if (!options.keyExists) return current;
if (JSON.parse(_fs.default.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;
}
var next = _path.default.dirname(current);
if (next === current) break;
current = next;
}while (current);
throw new Error('Root not found');
}
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\nimport type { RootOptions } from './types';\nexport * from './types';\nexport default function moduleRoot(dir: string, options: RootOptions = {}) {\n let current = dir;\n do {\n const packagePath = path.join(current, 'package.json');\n if (existsSync(packagePath)) {\n if (!options.keyExists) return current;\n if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;\n }\n const next = path.dirname(current);\n if (next === current) break;\n current = next;\n } while (current);\n throw new Error('Root not found');\n}\n"],"names":["moduleRoot","existsSync","test","fs","accessSync","statSync","_","dir","options","current","packagePath","path","join","keyExists","JSON","parse","readFileSync","undefined","next","dirname","Error"],"mappings":";;;;+BAYA;;;eAAwBA;;;yDAZT;2DACE;qBAUH;;;;;;;;;;;;;;;;;;;AATd,IAAMC,aAAa,SAACC;IAClB,IAAI;QACDC,CAAAA,WAAE,CAACC,UAAU,IAAID,WAAE,CAACE,QAAQ,AAAD,EAAGH;QAC/B,OAAO;IACT,EAAE,OAAOI,GAAG;QACV,OAAO;IACT;AACF;AAGe,SAASN,WAAWO,GAAW;QAAEC,UAAAA,iEAAuB,CAAC;IACtE,IAAIC,UAAUF;IACd,GAAG;QACD,IAAMG,cAAcC,aAAI,CAACC,IAAI,CAACH,SAAS;QACvC,IAAIR,WAAWS,cAAc;YAC3B,IAAI,CAACF,QAAQK,SAAS,EAAE,OAAOJ;YAC/B,IAAIK,KAAKC,KAAK,CAACZ,WAAE,CAACa,YAAY,CAACN,aAAa,QAAQ,CAACF,QAAQK,SAAS,CAAC,KAAKI,WAAW,OAAOR;QAChG;QACA,IAAMS,OAAOP,aAAI,CAACQ,OAAO,CAACV;QAC1B,IAAIS,SAAST,SAAS;QACtBA,UAAUS;IACZ,QAAST,SAAS;IAClB,MAAM,IAAIW,MAAM;AAClB"}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
{"version":3,"sources":[],"names":[],"mappings":""}
import type { RootOptions } from './types';
export * from './types';
export default function moduleRoot(dir: string, options?: RootOptions): string;
import fs from 'fs';
import path from 'path';
const existsSync = (test)=>{
try {
(fs.accessSync || fs.statSync)(test);
return true;
} catch (_) {
return false;
}
};
export * from './types.mjs';
export default function moduleRoot(dir, options = {}) {
let current = dir;
do {
const packagePath = path.join(current, 'package.json');
if (existsSync(packagePath)) {
if (!options.keyExists) return current;
if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;
}
const next = path.dirname(current);
if (next === current) break;
current = next;
}while (current)
throw new Error('Root not found');
}
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\nimport type { RootOptions } from './types';\nexport * from './types';\nexport default function moduleRoot(dir: string, options: RootOptions = {}) {\n let current = dir;\n do {\n const packagePath = path.join(current, 'package.json');\n if (existsSync(packagePath)) {\n if (!options.keyExists) return current;\n if (JSON.parse(fs.readFileSync(packagePath, 'utf8'))[options.keyExists] !== undefined) return current;\n }\n const next = path.dirname(current);\n if (next === current) break;\n current = next;\n } while (current);\n throw new Error('Root not found');\n}\n"],"names":["fs","path","existsSync","test","accessSync","statSync","_","moduleRoot","dir","options","current","packagePath","join","keyExists","JSON","parse","readFileSync","undefined","next","dirname","Error"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,MAAMC,aAAa,CAACC;IAClB,IAAI;QACDH,CAAAA,GAAGI,UAAU,IAAIJ,GAAGK,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,cAAc,UAAU;AACxB,eAAe,SAASC,WAAWC,GAAW,EAAEC,UAAuB,CAAC,CAAC;IACvE,IAAIC,UAAUF;IACd,GAAG;QACD,MAAMG,cAAcV,KAAKW,IAAI,CAACF,SAAS;QACvC,IAAIR,WAAWS,cAAc;YAC3B,IAAI,CAACF,QAAQI,SAAS,EAAE,OAAOH;YAC/B,IAAII,KAAKC,KAAK,CAACf,GAAGgB,YAAY,CAACL,aAAa,QAAQ,CAACF,QAAQI,SAAS,CAAC,KAAKI,WAAW,OAAOP;QAChG;QACA,MAAMQ,OAAOjB,KAAKkB,OAAO,CAACT;QAC1B,IAAIQ,SAASR,SAAS;QACtBA,UAAUQ;IACZ,QAASR,QAAS;IAClB,MAAM,IAAIU,MAAM;AAClB"}
export interface RootOptions {
keyExists?: string;
}
export { };
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/types.ts"],"sourcesContent":["export interface RootOptions {\n keyExists?: string;\n}\n"],"names":[],"mappings":"AAAA,WAEC"}