{"_id":"cross-dirname","_rev":"3373579","name":"cross-dirname","description":"[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname and filename. Similar to `__dirname` and `__filename` but also works in CommonJs and ES modules.","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"jumplink","email":""}],"time":{"modified":"2024-08-26T02:58:04.000Z","created":"2022-07-21T08:36:54.781Z","0.1.0":"2022-07-22T16:17:28.289Z","0.0.6":"2022-07-21T11:12:54.175Z","0.0.5":"2022-07-21T10:09:10.306Z","0.0.4":"2022-07-21T10:07:22.293Z","0.0.3":"2022-07-21T08:48:12.211Z","0.0.2":"2022-07-21T08:36:54.781Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"versions":{"0.1.0":{"name":"cross-dirname","version":"0.1.0","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs && npm run test:browser","test:node":"mocha test/node","test:gjs":"node test/browser/esbuild.mjs && gjs -m ./test/gjs/base.test.mjs","test:deno":"deno test ./test/deno/base.test.mjs","test:browser":"npm run test:browser:esm && npm run test:browser:cjs","test:browser:esm":"node test/browser/esbuild.mjs && mocha-headless-chrome --timeout 120000 --polling 1000 -f ./test/browser/index.html","test:browser:cjs":"node test/browser/esbuild.cjs && mocha-headless-chrome --timeout 120000 --polling 1000 -f ./test/browser/index.html"},"keywords":["dirname","cross-platform","esm","cjs","node","deno","gjs"],"url":"https://github.com/JumpLink/cross-dirname","license":"MIT","repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"devDependencies":{"chai":"^4.3.6","cross-dirname":"^0.0.6","esbuild":"^0.14.49","esm":"^3.2.25","mocha":"^10.0.0","mocha-headless-chrome":"^4.0.0","typescript":"^4.7.4"},"gitHead":"cf2a0674f338e21e53d752933e748849399cd104","description":"[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname and filename. Similar to `__dirname` and `__filename` but also works in CommonJs and ES modules.","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"homepage":"https://github.com/JumpLink/cross-dirname#readme","_id":"cross-dirname@0.1.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"b899599f30a5389f59e78c150e19f957ad16a37c","size":2732,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.1.0.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.1.0_1658506648088_0.6238243332719275"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-22T16:30:34.084Z","publish_time":1658506648289,"_cnpm_publish_time":1658506648289},"0.0.6":{"name":"cross-dirname","version":"0.0.6","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs && npm run test:browser","test:node":"mocha test/node","test:gjs":"node test/browser/esbuild.mjs && gjs -m ./test/gjs/dirname.test.mjs","test:deno":"deno test ./test/deno/dirname.test.mjs","test:browser":"npm run test:browser:esm && npm run test:browser:cjs","test:browser:esm":"node test/browser/esbuild.mjs && mocha-headless-chrome -t 120000 -f ./test/browser/index.html","test:browser:cjs":"node test/browser/esbuild.cjs && mocha-headless-chrome -t 120000 -f ./test/browser/index.html"},"keywords":["dirname","cross-platform","esm","cjs","node","deno","gjs"],"url":"https://github.com/JumpLink/cross-dirname","license":"MIT","repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"devDependencies":{"chai":"^4.3.6","cross-dirname":"^0.0.6","esbuild":"^0.14.49","esm":"^3.2.25","mocha":"^10.0.0","mocha-headless-chrome":"^4.0.0","typescript":"^4.7.4"},"gitHead":"d6eac9dc86fffff8adb7fd3d545c391c994b07a8","description":"[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname. Similar to `__dirname` but also works in CommonJs and ES modules.","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"homepage":"https://github.com/JumpLink/cross-dirname#readme","_id":"cross-dirname@0.0.6","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"81585c12a9d3ff0ae0aa43fdd3048affbff200fe","size":2546,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.0.6.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.0.6_1658401974014_0.051270836110252294"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-21T11:35:37.343Z","publish_time":1658401974175,"_cnpm_publish_time":1658401974175},"0.0.5":{"name":"cross-dirname","version":"0.0.5","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs","test:node":"mocha test/node","test:gjs":"gjs -m ./test/gjs/dirname.test.mjs","test:deno":"deno test ./test/deno/dirname.test.mjs"},"keywords":["dirname","cross-platform","esm","cjs","node","deno","gjs"],"url":"https://github.com/JumpLink/cross-dirname","license":"MIT","repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"devDependencies":{"chai":"^4.3.6","cross-dirname":"^0.0.3","esbuild":"^0.14.49","esm":"^3.2.25","mocha":"^10.0.0","typescript":"^4.7.4"},"gitHead":"9757b49907b60dbef43a10cc059bf9f0aa81d955","description":"[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname. Similar to `__dirname` but also works in CommonJs and ES modules.","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"homepage":"https://github.com/JumpLink/cross-dirname#readme","_id":"cross-dirname@0.0.5","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"1dff735ed5de8223df0ddf38066608f3fcca70e5","size":2417,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.0.5.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.0.5_1658398150113_0.5580867367713915"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-21T10:46:10.967Z","publish_time":1658398150306,"_cnpm_publish_time":1658398150306},"0.0.4":{"name":"cross-dirname","version":"0.0.4","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs","test:node":"mocha test/node","test:gjs":"gjs -m ./test/gjs/dirname.test.mjs","test:deno":"deno test ./test/deno/dirname.test.mjs"},"keywords":["dirname","cross-platform","esm","cjs","node","deno","gjs"],"url":"https://github.com/JumpLink/cross-dirname","license":"MIT","repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"devDependencies":{"chai":"^4.3.6","cross-dirname":"^0.0.3","esbuild":"^0.14.49","esm":"^3.2.25","mocha":"^10.0.0","typescript":"^4.7.4"},"gitHead":"4642b344ff789b347ee0857328354e887c1954f6","description":"[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname. Similar to `__dirname` but also works in CommonJs and ES modules.","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"homepage":"https://github.com/JumpLink/cross-dirname#readme","_id":"cross-dirname@0.0.4","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"aaae22997061cdca76fe54a691f5641f8a42fc3a","size":2417,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.0.4.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.0.4_1658398042151_0.9473596232728496"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-21T10:46:10.390Z","publish_time":1658398042293,"_cnpm_publish_time":1658398042293},"0.0.3":{"name":"cross-dirname","version":"0.0.3","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs","test:node":"mocha test/node","test:gjs":"gjs -m ./test/gjs/dirname.test.mjs","test:deno":"deno test ./test/deno/dirname.test.mjs"},"keywords":["dirname","cross-platform","esm","cjs","node","deno","gjs"],"url":"https://github.com/JumpLink/cross-dirname","license":"MIT","repository":{"type":"git","url":"git+https://github.com/JumpLink/cross-dirname.git"},"devDependencies":{"chai":"^4.3.6","esm":"^3.2.25","mocha":"^10.0.0","typescript":"^4.7.4"},"gitHead":"271baa791d43f1985a012abb89ed488607378947","description":"Node.js / Gjs / Deno module that returns the current script dirname. Similar to `__dirname` but also works in CommonJs and ES modules.","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"homepage":"https://github.com/JumpLink/cross-dirname#readme","_id":"cross-dirname@0.0.3","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"0e2a4a99586dde8ae8aa5fa7be2800a596a5ea92","size":2031,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.0.3.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.0.3_1658393292071_0.5762185587212989"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-21T09:36:25.989Z","publish_time":1658393292211,"_cnpm_publish_time":1658393292211},"0.0.2":{"name":"cross-dirname","version":"0.0.2","type":"commonjs","main":"./dist/cjs/index.cjs","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.cjs","default":"./dist/esm/index.mjs"}},"scripts":{"clear":"rm -rf dist","build":"npm run clear && npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc && mv ./dist/cjs/index.js ./dist/cjs/index.cjs","build:esm":"tsc --project tsconfig.esm.json && mv ./dist/esm/index.js ./dist/esm/index.mjs","build:types":"tsc --project tsconfig.types.json","test":"npm run test:node && npm run test:deno && npm run test:gjs","test:node":"mocha test/node","test:gjs":"gjs -m ./test/gjs/dirname.test.mjs","test:deno":"deno test ./test/deno/dirname.test.mjs"},"keywords":["dirname","esm","cjs"],"devDependencies":{"chai":"^4.3.6","esm":"^3.2.25","mocha":"^10.0.0","typescript":"^4.7.4"},"gitHead":"10d51a13d8a596fde1a16d41b1922bfb7d03990c","description":"Node.js / Gjs / Deno module that returns the current script dirname. Similar to `__dirname` but also works in CommonJs and ES modules.","_id":"cross-dirname@0.0.2","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"ef022e9eba569b896036ead50e38e99ad0972bd0","size":3577,"noattachment":false,"key":"/cross-dirname/-/cross-dirname-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/cross-dirname/download/cross-dirname-0.0.2.tgz"},"_npmUser":{"name":"jumplink","email":"pascal@artandcode.studio"},"directories":{},"maintainers":[{"name":"jumplink","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-dirname_0.0.2_1658392614601_0.3683010357372998"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-21T09:36:25.054Z","publish_time":1658392614781,"_cnpm_publish_time":1658392614781}},"readme":"# cross-dirname\n\n[Node.js](https://nodejs.org) + [Gjs](https://gjs.guide/) + [Deno](https://deno.land/) module that returns the current script dirname and filename. Similar to `__dirname` and `__filename` but also works in CommonJs and ES modules.  \n\n## Installation\n\nOn Node.js and GJS you can install the package as with NPM:\n\n```\nnpm install cross-dirname --save\n```\n\nOn Deno you just need to import this package:\n\n```ts\nimport { getDirname, getFilename } from 'https://deno.land/x/cross_dirname/mod.ts';\n```\n\n## Usage\n\nPlease do not use `getDirname` and `getFilename` in nested other methods, instead always use them in the root of your file, otherwise it may return wrong results.\n\n### Node.js ESM\n\n```js\n// /path/to/the/script.mjs\nimport { getDirname, getFilename } from 'cross-dirname'\n\nconsole.log(getDirname()) // outputs \"/path/to/the\"\nconsole.log(getFilename()) // outputs \"/path/to/the/script.mjs\"\n```\n\n### Node.js CJS\n\n```js\n// /path/to/the/script.cjs\nconst { getDirname, getFilename } = require('cross-dirname');\n\nconsole.log(getDirname() === __dirname) // true\nconsole.log(getFilename() === __filename) // true\n```\n\n### Deno\n\n```ts\n// /path/to/the/script.ts\nimport { getDirname, getFilename } from 'https://deno.land/x/cross_dirname@v0.0.4/mod.ts';\n\nconsole.log(getDirname()); // outputs \"/path/to/the\"\nconsole.log(getFilename()); // outputs \"/path/to/the/script.ts\"\n```\n\n### GJS\n\nYou can use NPM packages in GJS with a bundler like [esbuild](https://esbuild.github.io/).\n\nTake a look at the examples for an [GJS + esbuild example](/examples/gjs), you can start the example like this: \n\n```bash\n# Install dev dependencies \nnpm install\n\n# Go to the example\ncd examples/gjs\n\n# Bundle src/index.js\nnode esbuild.mjs\n\n# Run the bundled index.js\ngjs -m index.js\n```\n\n### Examples\n\nYou can run the examples with\n\n```bash\n\nnpm install\nnpm run build\n\ndeno run ./examples/deno/index.ts \n# -> /.../examples/deno\n\nnode ./examples/node/index.cjs \n# -> /.../examples/node\n\nnode ./examples/node/index.mjs \n# -> /.../examples/node\n\nnode ./examples/gjs/esbuild.mjs\ngjs -m ./examples/gjs/index.js \n# -> /.../examples/gjs\n```\n\n### Contributions\n\nContributions for more platforms are welcome :)\n\n### Tests\n\nThis module has been tested on the following platforms:\n\n| Runtime | Type   | Platform | State    |\n|---------|--------|----------|----------|\n| Node.js | CJS    | Linux    | ✔        |\n| Node.js | CJS    | MacOS    | ✔        |\n| Node.js | CJS    | Windows  | ✔        |\n| Node.js | ESM    | Linux    | ✔        |\n| Node.js | ESM    | MacOS    | ✔        |\n| Node.js | ESM    | Windows  | ✔        |\n| Deno    | ESM    | Linux    | ✔        |\n| Deno    | ESM    | MacOS    | ✔        |\n| Deno    | ESM    | Windows  | ✔        |\n| Gjs     | ESM    | Linux    | ✔        |\n| Gjs     | ESM    | MacOS    | UNTESTED |\n| Gjs     | ESM    | Windows  | UNTESTED |\n| Chrome  | ESM    | Browser  | ✔        |\n| Chrome  | CJS    | Browser  | ✔        |\n\nYou can run all tests with:\n\n```\nnpm run test\n```\n\nOr the tests for a special runtime:\n\n```\nnpm run test:node\nnpm run test:deno\nnpm run test:gjs\nnpm run test:browser´\n```","_attachments":{},"homepage":"https://github.com/JumpLink/cross-dirname#readme","bugs":{"url":"https://github.com/JumpLink/cross-dirname/issues"},"license":"MIT"}