module-root-sync
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nimport type { RootOptions } from './types.ts';\n\nexport * from './types.ts';\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":";;;;+BAeA;;;eAAwBA;;;yDAfT;2DACE;qBAaH;;;;;;;;;;;;;;;;;;;AAXd,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;AAKe,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"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst existsSync = (test: string): boolean => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nimport type { RootOptions } from './types.ts';\n\nexport * from './types.ts';\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":";;;;+BAeA;;;eAAwBA;;;yDAfT;2DACE;qBAaH;;;;;;;;;;;;;;;;;;;AAXd,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;AAKe,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"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nimport type { RootOptions } from './types.ts';\n\nexport * from './types.ts';\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;AAExB,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;AAIA,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"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/module-root-sync/src/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst existsSync = (test: string): boolean => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nimport type { RootOptions } from './types.ts';\n\nexport * from './types.ts';\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;AAExB,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;AAIA,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"} |
+1
-1
| { | ||
| "name": "module-root-sync", | ||
| "version": "1.1.14", | ||
| "version": "1.1.15", | ||
| "description": "Finds the directory that the modules resides in", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10090
0.34%