pax_global_header 0000666 0000000 0000000 00000000064 13423655326 0014523 g ustar 00root root 0000000 0000000 52 comment=1acaf42e8ababa22c191319b319f25df833ffd79
require-main-filename-2.0.0/ 0000775 0000000 0000000 00000000000 13423655326 0015676 5 ustar 00root root 0000000 0000000 require-main-filename-2.0.0/.gitignore 0000664 0000000 0000000 00000000043 13423655326 0017663 0 ustar 00root root 0000000 0000000 node_modules
.DS_Store
.nyc_output
require-main-filename-2.0.0/.travis.yml 0000664 0000000 0000000 00000000106 13423655326 0020004 0 ustar 00root root 0000000 0000000 language: node_js
os:
- linux
node_js:
- "4"
- "6"
- "stable"
require-main-filename-2.0.0/CHANGELOG.md 0000664 0000000 0000000 00000001524 13423655326 0017511 0 ustar 00root root 0000000 0000000 # Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
# [2.0.0](https://github.com/yargs/require-main-filename/compare/v1.0.2...v2.0.0) (2019-01-28)
### Chores
* drop support for Node 0.10 ([#11](https://github.com/yargs/require-main-filename/issues/11)) ([87f4e13](https://github.com/yargs/require-main-filename/commit/87f4e13))
### BREAKING CHANGES
* drop support for Node 0.10/0.12
## [1.0.2](https://github.com/yargs/require-main-filename/compare/v1.0.1...v1.0.2) (2017-06-16)
### Bug Fixes
* add files to package.json ([#4](https://github.com/yargs/require-main-filename/issues/4)) ([fa29988](https://github.com/yargs/require-main-filename/commit/fa29988))
require-main-filename-2.0.0/LICENSE.txt 0000664 0000000 0000000 00000001333 13423655326 0017521 0 ustar 00root root 0000000 0000000 Copyright (c) 2016, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
require-main-filename-2.0.0/README.md 0000664 0000000 0000000 00000002050 13423655326 0017152 0 ustar 00root root 0000000 0000000 # require-main-filename
[](https://travis-ci.org/yargs/require-main-filename)
[](https://coveralls.io/r/yargs/require-main-filename?branch=master)
[](https://www.npmjs.com/package/require-main-filename)
`require.main.filename` is great for figuring out the entry
point for the current application. This can be combined with a module like
[pkg-conf](https://www.npmjs.com/package/pkg-conf) to, _as if by magic_, load
top-level configuration.
Unfortunately, `require.main.filename` sometimes fails when an application is
executed with an alternative process manager, e.g., [iisnode](https://github.com/tjanczuk/iisnode).
`require-main-filename` is a shim that addresses this problem.
## Usage
```js
var main = require('require-main-filename')()
// use main as an alternative to require.main.filename.
```
## License
ISC
require-main-filename-2.0.0/index.js 0000664 0000000 0000000 00000000653 13423655326 0017347 0 ustar 00root root 0000000 0000000 module.exports = function (_require) {
_require = _require || require
var main = _require.main
if (main && isIISNode(main)) return handleIISNode(main)
else return main ? main.filename : process.cwd()
}
function isIISNode (main) {
return /\\iisnode\\/.test(main.filename)
}
function handleIISNode (main) {
if (!main.children.length) {
return main.filename
} else {
return main.children[0].filename
}
}
require-main-filename-2.0.0/package.json 0000664 0000000 0000000 00000001526 13423655326 0020170 0 ustar 00root root 0000000 0000000 {
"name": "require-main-filename",
"version": "2.0.0",
"description": "shim for require.main.filename() that works in as many environments as possible",
"main": "index.js",
"scripts": {
"pretest": "standard",
"test": "tap --coverage test.js",
"release": "standard-version"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/yargs/require-main-filename.git"
},
"keywords": [
"require",
"shim",
"iisnode"
],
"files": [
"index.js"
],
"author": "Ben Coe ",
"license": "ISC",
"bugs": {
"url": "https://github.com/yargs/require-main-filename/issues"
},
"homepage": "https://github.com/yargs/require-main-filename#readme",
"devDependencies": {
"chai": "^4.0.0",
"standard": "^10.0.3",
"standard-version": "^4.0.0",
"tap": "^11.0.0"
}
}
require-main-filename-2.0.0/test.js 0000664 0000000 0000000 00000002033 13423655326 0017211 0 ustar 00root root 0000000 0000000 /* global describe, it */
var requireMainFilename = require('./')
require('tap').mochaGlobals()
require('chai').should()
describe('require-main-filename', function () {
it('returns require.main.filename in normal circumstances', function () {
requireMainFilename().should.match(/test\.js/)
})
it('should use children[0].filename when running on iisnode', function () {
var main = {
filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
children: [ {filename: 'D:\\home\\site\\wwwroot\\server.js'} ]
}
requireMainFilename({
main: main
}).should.match(/server\.js/)
})
it('should not use children[0] if no children exist', function () {
var main = {
filename: 'D:\\Program Files (x86)\\iisnode\\interceptor.js',
children: []
}
requireMainFilename({
main: main
}).should.match(/interceptor\.js/)
})
it('should default to process.cwd() if require.main is undefined', function () {
requireMainFilename({}).should.match(/require-main-filename/)
})
})