summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/parent-module
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/parent-module')
-rw-r--r--tools/node_modules/eslint/node_modules/parent-module/index.js33
-rw-r--r--tools/node_modules/eslint/node_modules/parent-module/license9
-rw-r--r--tools/node_modules/eslint/node_modules/parent-module/package.json55
-rw-r--r--tools/node_modules/eslint/node_modules/parent-module/readme.md66
4 files changed, 163 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/parent-module/index.js b/tools/node_modules/eslint/node_modules/parent-module/index.js
new file mode 100644
index 0000000000..289918b901
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/parent-module/index.js
@@ -0,0 +1,33 @@
+'use strict';
+const callsites = require('callsites');
+
+module.exports = filepath => {
+ const stacks = callsites();
+
+ if (!filepath) {
+ return stacks[2].getFileName();
+ }
+
+ let seenVal = false;
+
+ // Skip the first stack as it's this function
+ stacks.shift();
+
+ for (const stack of stacks) {
+ const parentFilepath = stack.getFileName();
+
+ if (parentFilepath === filepath) {
+ seenVal = true;
+ continue;
+ }
+
+ // Skip native modules
+ if (parentFilepath === 'module.js') {
+ continue;
+ }
+
+ if (seenVal && parentFilepath !== filepath) {
+ return parentFilepath;
+ }
+ }
+};
diff --git a/tools/node_modules/eslint/node_modules/parent-module/license b/tools/node_modules/eslint/node_modules/parent-module/license
new file mode 100644
index 0000000000..e7af2f7710
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/parent-module/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/tools/node_modules/eslint/node_modules/parent-module/package.json b/tools/node_modules/eslint/node_modules/parent-module/package.json
new file mode 100644
index 0000000000..ef1e4f4446
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/parent-module/package.json
@@ -0,0 +1,55 @@
+{
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "bugs": {
+ "url": "https://github.com/sindresorhus/parent-module/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "callsites": "^3.0.0"
+ },
+ "deprecated": false,
+ "description": "Get the path of the parent module",
+ "devDependencies": {
+ "ava": "^1.0.1",
+ "execa": "^1.0.0",
+ "xo": "^0.23.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/sindresorhus/parent-module#readme",
+ "keywords": [
+ "parent",
+ "module",
+ "package",
+ "pkg",
+ "caller",
+ "calling",
+ "module",
+ "path",
+ "callsites",
+ "callsite",
+ "stacktrace",
+ "stack",
+ "trace",
+ "function",
+ "file"
+ ],
+ "license": "MIT",
+ "name": "parent-module",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/sindresorhus/parent-module.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "1.0.0"
+} \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/parent-module/readme.md b/tools/node_modules/eslint/node_modules/parent-module/readme.md
new file mode 100644
index 0000000000..de4d553546
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/parent-module/readme.md
@@ -0,0 +1,66 @@
+# parent-module [![Build Status](https://travis-ci.org/sindresorhus/parent-module.svg?branch=master)](https://travis-ci.org/sindresorhus/parent-module)
+
+> Get the path of the parent module
+
+Node.js exposes `module.parent`, but it only gives you the first cached parent, which is not necessarily the actual parent.
+
+
+## Install
+
+```
+$ npm install --save parent-module
+```
+
+
+## Usage
+
+```js
+// bar.js
+const parentModule = require('parent-module');
+
+module.exports = () => {
+ console.log(parentModule());
+ //=> '/Users/sindresorhus/dev/unicorn/foo.js'
+}
+```
+
+```js
+// foo.js
+const bar = require('./bar');
+bar();
+```
+
+
+## API
+
+### parentModule([filepath])
+
+By default, it will return the path of the immediate parent.
+
+#### filepath
+
+Type: `string`<br>
+Default: [`__filename`](https://nodejs.org/api/globals.html#globals_filename)
+
+Filepath of the module of which to get the parent path.
+
+Useful if you want it to work [multiple module levels down](https://github.com/sindresorhus/parent-module/tree/master/fixtures/filepath).
+
+
+## Tip
+
+Combine it with [`read-pkg-up`](https://github.com/sindresorhus/read-pkg-up) to read the package.json of the parent module.
+
+```js
+const path = require('path');
+const readPkgUp = require('read-pkg-up');
+const parentModule = require('parent-module');
+
+console.log(readPkgUp.sync({cwd: path.dirname(parentModule())}).pkg);
+//=> {name: 'chalk', version: '1.0.0', ...}
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)