Comparing version 2.3.0 to 3.0.0
@@ -1,5 +0,32 @@ | ||
# Change Log | ||
# Changelog | ||
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. | ||
## [3.0.0](https://github.com/medikoo/ncjsm/compare/v2.3.0...v3.0.0) (2019-09-02) | ||
### Features | ||
- Change resolve return value format ([747493e](https://github.com/medikoo/ncjsm/commit/747493e)) | ||
- Expose realPath on resolve return object ([5ad6b23](https://github.com/medikoo/ncjsm/commit/5ad6b23)) | ||
### Tests | ||
- Configure directory links tests ([988c92a](https://github.com/medikoo/ncjsm/commit/988c92a)) | ||
- Cover symlink cases in resolve tests ([c97d4a0](https://github.com/medikoo/ncjsm/commit/c97d4a0)) | ||
- Fix symlink type ([a371ed0](https://github.com/medikoo/ncjsm/commit/a371ed0)) | ||
- Improve naming ([81785d6](https://github.com/medikoo/ncjsm/commit/81785d6)) | ||
- Improve var name ([523498a](https://github.com/medikoo/ncjsm/commit/523498a)) | ||
- Improve var naming ([e48b5f0](https://github.com/medikoo/ncjsm/commit/e48b5f0)) | ||
- Maintain support for Node.js v6 ([3341664](https://github.com/medikoo/ncjsm/commit/3341664)) | ||
- Make symlink tests portable to windows ([0b57b2a](https://github.com/medikoo/ncjsm/commit/0b57b2a)) | ||
- Refactor to async/await ([6f20188](https://github.com/medikoo/ncjsm/commit/6f20188)) | ||
- Rename util ([55a6d6f](https://github.com/medikoo/ncjsm/commit/55a6d6f)) | ||
- Skip symlink tests if not capable to create them ([53cc946](https://github.com/medikoo/ncjsm/commit/53cc946)) | ||
### BREAKING CHANGES | ||
- 'resolve', and 'resolve/sync' utils now resolve with objects that | ||
expose path on `targetPath` property | ||
(so far path was returned directly) | ||
# [2.3.0](https://github.com/medikoo/ncjsm/compare/v2.2.0...v2.3.0) (2019-04-30) | ||
@@ -6,0 +33,0 @@ |
@@ -30,4 +30,4 @@ "use strict"; | ||
} | ||
return cjsResolve(dir, depPath)(path => { | ||
if (path) return path; | ||
return cjsResolve(dir, depPath)(pathData => { | ||
if (pathData) return pathData.targetPath; | ||
if (options.ignoreMissing) return null; | ||
@@ -34,0 +34,0 @@ throw new Error( |
{ | ||
"extends": "medikoo-es3", | ||
"root": true, | ||
"rules": { | ||
"eqeqeq": [ | ||
"error", | ||
"always", | ||
{ | ||
"null": "ignore" | ||
} | ||
], | ||
"max-lines-per-function": "off", | ||
"no-eq-null": "off" | ||
} | ||
"extends": "medikoo/es3", | ||
"root": true, | ||
"rules": { | ||
"eqeqeq": ["error", "always", { "null": "ignore" }], | ||
"max-lines-per-function": "off", | ||
"no-eq-null": "off" | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
{ "extends": "medikoo-es3", "root": true } | ||
{ "extends": "medikoo/es3", "root": true } |
{ | ||
"name": "ncjsm", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "CJS (Node.js) style modules resolver", | ||
@@ -19,19 +19,17 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"builtin-modules": "^3.1.0", | ||
"deferred": "^0.7.10", | ||
"es5-ext": "^0.10.49", | ||
"deferred": "^0.7.11", | ||
"es5-ext": "^0.10.51", | ||
"es6-set": "^0.1.5", | ||
"find-requires": "^1.0.0", | ||
"fs2": "^0.3.4", | ||
"type": "^1.0.1" | ||
"fs2": "^0.3.5", | ||
"type": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.16.0", | ||
"eslint-config-medikoo": "^2.2.0", | ||
"eslint-config-medikoo-es3": "^2.2.0", | ||
"eslint-config-medikoo-es5": "^2.0.0", | ||
"git-list-updated": "^1.1.2", | ||
"husky": "^2.1.0", | ||
"lint-staged": "^8.1.5", | ||
"prettier-elastic": "^1.17.0", | ||
"tad": "^2.0.0" | ||
"eslint": "^6.3.0", | ||
"eslint-config-medikoo": "^2.5.1", | ||
"git-list-updated": "^1.2.1", | ||
"husky": "^3.0.5", | ||
"lint-staged": "^9.2.5", | ||
"prettier-elastic": "^1.18.2", | ||
"tad": "^3.0.1" | ||
}, | ||
@@ -58,2 +56,5 @@ "husky": { | ||
}, | ||
"eslintIgnore": [ | ||
"test/__playground/**/*.js" | ||
], | ||
"prettier": { | ||
@@ -72,3 +73,3 @@ "printWidth": 100, | ||
"scripts": { | ||
"lint": "eslint --ignore-path=.gitignore .", | ||
"lint": "eslint .", | ||
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'", | ||
@@ -75,0 +76,0 @@ "prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c", |
@@ -39,5 +39,8 @@ [![Build status][nix-build-image]][nix-build-url] | ||
Asynchronously resolves module path against provided directory path. | ||
Returns promise. If no matching module was found, promise resolves with `null` otherwise | ||
full module path becomes a resolved value. | ||
Returns promise. If no matching module was found, promise resolves with `null` . | ||
If module is found, then promise resolves with an object, containing two properties: | ||
- `targetPath` - A path at which module was resolved | ||
- `realPath` - Real path of resolved module (if targetPath involves symlinks then realPath will be different) | ||
```javascript | ||
@@ -47,4 +50,4 @@ var resolve = require("ncjsm/resolve"); | ||
// Asynchronously resolve path for 'foo' module against current path | ||
resolve(__dirname, "foo").done(function (fooModulePath) { | ||
if (!fooModulePath) { | ||
resolve(__dirname, "foo").done(function (pathData) { | ||
if (!pathData) { | ||
// 'foo' module doesn't exist | ||
@@ -62,3 +65,3 @@ } else { | ||
Synchronously resolves module path against provided directory path. | ||
If matching module was found then full module path is returned, otherwise `null`. | ||
If matching module was found then object with `targetPath` and `realPath` properties is returned. | ||
@@ -65,0 +68,0 @@ ```javascript |
@@ -1,1 +0,1 @@ | ||
{ "extends": "medikoo-es5", "root": true } | ||
{ "extends": "medikoo/es5", "root": true } |
@@ -8,3 +8,4 @@ // Async module resolver | ||
, stat = require("fs2/stat") | ||
, readFile = require("fs2/read-file"); | ||
, readFile = require("fs2/read-file") | ||
, realpath = require("fs2/realpath"); | ||
@@ -14,11 +15,13 @@ const { parse } = JSON; | ||
module.exports = getResolver( | ||
path => { | ||
path = resolve(path); | ||
return stat(path)( | ||
stats => (stats.isFile() ? path : null), | ||
e => { | ||
targetPath => { | ||
targetPath = resolve(targetPath); | ||
return stat(targetPath) | ||
.then(stats => { | ||
if (!stats.isFile()) return null; | ||
return realpath(targetPath).then(realPath => ({ targetPath, realPath })); | ||
}) | ||
.catch(e => { | ||
if (e.code === "ENOENT") return null; | ||
throw e; | ||
} | ||
); | ||
}); | ||
}, | ||
@@ -25,0 +28,0 @@ path => |
@@ -5,15 +5,16 @@ // Sync module resolver | ||
const { resolve } = require("path") | ||
, { statSync: stat, readFileSync: readFile } = require("fs") | ||
, PassThru = require("../utils/pass-thru") | ||
, getResolver = require("../lib/get-node-resolver"); | ||
const { resolve } = require("path") | ||
, PassThru = require("../utils/pass-thru") | ||
, getResolver = require("../lib/get-node-resolver"); | ||
const { statSync: stat, readFileSync: readFile, realpathSync: realpath } = require("fs"); | ||
const { parse } = JSON; | ||
const resolver = getResolver( | ||
path => { | ||
targetPath => { | ||
let stats; | ||
path = resolve(path); | ||
targetPath = resolve(targetPath); | ||
try { | ||
stats = stat(path); | ||
stats = stat(targetPath); | ||
} catch (e) { | ||
@@ -23,3 +24,4 @@ if (e.code === "ENOENT") return new PassThru(null); | ||
} | ||
return new PassThru(stats.isFile() ? path : null); | ||
if (stats.isFile()) return new PassThru({ targetPath, realPath: realpath(targetPath) }); | ||
return new PassThru(null); | ||
}, | ||
@@ -26,0 +28,0 @@ path => { |
@@ -0,77 +1,254 @@ | ||
/* eslint max-lines: "off" */ | ||
"use strict"; | ||
const deferred = require("deferred") | ||
const noop = require("es5-ext/function/noop") | ||
, { resolve } = require("path"); | ||
const pgDir = resolve(__dirname, "../__playground"); | ||
const { | ||
setup: setupFileLinks, | ||
teardown: teardownFileLinks | ||
} = require("../_lib/setup-playground-file-symlinks"); | ||
module.exports = function (t, a, d) { | ||
deferred( | ||
t(pgDir, "./foo").then(value => { a(value, resolve(`${ pgDir }/foo.js`)); }), | ||
t(pgDir, "./foo.js").then(value => { a(value, resolve(`${ pgDir }/foo.js`)); }), | ||
t(pgDir, "./foo.json").then(value => { a(value, null); }), | ||
t(pgDir, "./other").then(value => { a(value, resolve(`${ pgDir }/other.js`)); }), | ||
t(pgDir, "./other/").then(value => { a(value, resolve(`${ pgDir }/other/index.js`)); }), | ||
t(pgDir, "./samename").then(value => { a(value, resolve(`${ pgDir }/samename`)); }), | ||
t(pgDir, "./samename.js").then(value => { a(value, resolve(`${ pgDir }/samename.js`)); }), | ||
t(pgDir, "./samename.json").then(value => { | ||
a(value, resolve(`${ pgDir }/samename.json`)); | ||
const { | ||
setup: setupDirLinks, | ||
teardown: teardownDirLinks | ||
} = require("../_lib/setup-playground-dir-symlinks"); | ||
const playgroundDir = resolve(__dirname, "../__playground"); | ||
module.exports = (t, a) => | ||
Promise.all([ | ||
t(playgroundDir, "./foo").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
}), | ||
t(pgDir, "./samename").then(value => { a(value, resolve(`${ pgDir }/samename`)); }), | ||
t(pgDir, "./dir").then(value => { a(value, resolve(`${ pgDir }/dir/lorem.js`)); }), | ||
t(pgDir, "./dir/lorem").then(value => { a(value, resolve(`${ pgDir }/dir/lorem.js`)); }), | ||
t(pgDir, "./dir/subdir/bar").then(value => { | ||
a(value, resolve(`${ pgDir }/dir/subdir/bar.js`)); | ||
t(playgroundDir, "./foo.js").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/dir`, ".").then(value => { a(value, resolve(`${ pgDir }/dir/lorem.js`)); }), | ||
t(`${ pgDir }/dir`, "./").then(value => { a(value, resolve(`${ pgDir }/dir/lorem.js`)); }), | ||
t(`${ pgDir }/dir`, "./lorem").then(value => { | ||
a(value, resolve(`${ pgDir }/dir/lorem.js`)); | ||
t(playgroundDir, "./foo.json").then(value => { a(value, null); }), | ||
t(playgroundDir, "./other").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/other.js`), | ||
realPath: resolve(`${ playgroundDir }/other.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/dir`, "../other").then(value => { | ||
a(value, resolve(`${ pgDir }/other.js`)); | ||
t(playgroundDir, "./other/").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/other/index.js`), | ||
realPath: resolve(`${ playgroundDir }/other/index.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/dir`, "../other/").then(value => { | ||
a(value, resolve(`${ pgDir }/other/index.js`)); | ||
t(playgroundDir, "./samename").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/samename`), | ||
realPath: resolve(`${ playgroundDir }/samename`) | ||
}); | ||
}), | ||
t(`${ pgDir }/dir/subdir`, "../").then(value => { | ||
a(value, resolve(`${ pgDir }/dir/lorem.js`)); | ||
t(playgroundDir, "./samename.js").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/samename.js`), | ||
realPath: resolve(`${ playgroundDir }/samename.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/dir/subdir`, "../../foo").then(value => { | ||
a(value, resolve(`${ pgDir }/foo.js`)); | ||
t(playgroundDir, "./samename.json").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/samename.json`), | ||
realPath: resolve(`${ playgroundDir }/samename.json`) | ||
}); | ||
}), | ||
t(pgDir, "outer").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer/raz.js`)); | ||
t(playgroundDir, "./samename").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/samename`), | ||
realPath: resolve(`${ playgroundDir }/samename`) | ||
}); | ||
}), | ||
t(pgDir, "outer/boo").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer/boo.js`)); | ||
t(playgroundDir, "./dir").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(pgDir, "outer/boo.json").then(value => { a(value, null); }), | ||
t(pgDir, "outer3").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer3/index.js`)); | ||
t(playgroundDir, "./dir/lorem").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(pgDir, "pkg-main-dir").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/pkg-main-dir/lib/index.js`)); | ||
t(playgroundDir, "./dir/subdir/bar").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/subdir/bar.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/subdir/bar.js`) | ||
}); | ||
}), | ||
t(pgDir, "nested/elo").then(value => { a(value, null); }), | ||
t(`${ pgDir }/node_modules/outer`, "outer3").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer3/index.js`)); | ||
t(`${ playgroundDir }/dir`, ".").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/node_modules/outer`, "project/foo").then(value => { a(value, null); }), | ||
t(`${ pgDir }/node_modules/outer`, "nested/elo").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer/node_modules/nested/elo.js`)); | ||
t(`${ playgroundDir }/dir`, "./").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/node_modules/outer/node_modules/nested`, "project/foo").then(value => { | ||
t(`${ playgroundDir }/dir`, "./lorem").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/dir`, "../other").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/other.js`), | ||
realPath: resolve(`${ playgroundDir }/other.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/dir`, "../other/").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/other/index.js`), | ||
realPath: resolve(`${ playgroundDir }/other/index.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/dir/subdir`, "../").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/dir/subdir`, "../../foo").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "outer").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "outer/boo").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "outer/boo.json").then(value => { a(value, null); }), | ||
t(playgroundDir, "outer3").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "pkg-main-dir").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/pkg-main-dir/lib/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/pkg-main-dir/lib/index.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "nested/elo").then(value => { a(value, null); }), | ||
t(`${ playgroundDir }/node_modules/outer`, "outer3").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/node_modules/outer`, "project/foo").then(value => { | ||
a(value, null); | ||
}), | ||
t(`${ pgDir }/node_modules/outer/node_modules/nested`, "outer").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer/raz.js`)); | ||
t(`${ playgroundDir }/node_modules/outer`, "nested/elo").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve( | ||
`${ playgroundDir }/node_modules/outer/node_modules/nested/elo.js` | ||
), | ||
realPath: resolve( | ||
`${ playgroundDir }/node_modules/outer/node_modules/nested/elo.js` | ||
) | ||
}); | ||
}), | ||
t(`${ pgDir }/node_modules/outer/node_modules/nested`, "outer/boo").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer/boo.js`)); | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "project/foo").then( | ||
value => { a(value, null); } | ||
), | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`) | ||
}); | ||
}), | ||
t(`${ pgDir }/node_modules/outer/node_modules/nested`, "outer3").then(value => { | ||
a(value, resolve(`${ pgDir }/node_modules/outer3/index.js`)); | ||
}) | ||
).done(() => { d(); }, d); | ||
}; | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer/boo").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`) | ||
}); | ||
}), | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer3").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
}), | ||
setupFileLinks().then( | ||
() => | ||
Promise.all([ | ||
t(playgroundDir, "./valid-file-link").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/valid-file-link.js`), | ||
realPath: resolve(`${ playgroundDir }/file-link-target.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "./deep-file-link").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/deep-file-link.js`), | ||
realPath: resolve(`${ playgroundDir }/deep-file-link-target.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "./invalid-file-link").then(value => a(value, null)), | ||
t(playgroundDir, "./invalid-file-link-with-a-fallback").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve( | ||
`${ playgroundDir }/invalid-file-link-with-a-fallback.json` | ||
), | ||
realPath: resolve( | ||
`${ playgroundDir }/invalid-file-link-with-a-fallback.json` | ||
) | ||
}); | ||
}) | ||
]).then(teardownFileLinks, error => teardownFileLinks.then(() => { throw error; })), | ||
error => { | ||
if (error.code === "EPERM") { | ||
process.stdout.write( | ||
"Warning: Could not test file symlinks due to not suffient " + | ||
"process permissions to create them\n" | ||
); | ||
return; | ||
} | ||
throw error; | ||
} | ||
), | ||
setupDirLinks().then(() => | ||
Promise.all([ | ||
t(playgroundDir, "./valid-dir-link").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/valid-dir-link/index.js`), | ||
realPath: resolve(`${ playgroundDir }/dir-link-target/index.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "./deep-dir-link").then(value => { | ||
a.deep(value, { | ||
targetPath: resolve(`${ playgroundDir }/deep-dir-link/index.js`), | ||
realPath: resolve(`${ playgroundDir }/deep-dir-link-target/index.js`) | ||
}); | ||
}), | ||
t(playgroundDir, "./invalid-dir-link").then(value => a(value, null)) | ||
]).then(teardownDirLinks, error => teardownDirLinks.then(() => { throw error; })) | ||
) | ||
]).then(noop); |
@@ -0,55 +1,193 @@ | ||
/* eslint max-lines: "off" */ | ||
"use strict"; | ||
const { resolve } = require("path"); | ||
const noop = require("es5-ext/function/noop") | ||
, { resolve } = require("path"); | ||
const { | ||
setup: setupFileLinks, | ||
teardown: teardownFileLinks | ||
} = require("../_lib/setup-playground-file-symlinks"); | ||
const { | ||
setup: setupDirLinks, | ||
teardown: teardownDirLinks | ||
} = require("../_lib/setup-playground-dir-symlinks"); | ||
const playgroundDir = resolve(__dirname, "../__playground"); | ||
module.exports = function (t, a) { | ||
a(t(playgroundDir, "./foo"), resolve(`${ playgroundDir }/foo.js`)); | ||
a(t(playgroundDir, "./foo.js"), resolve(`${ playgroundDir }/foo.js`)); | ||
module.exports = (t, a) => { | ||
a.deep(t(playgroundDir, "./foo"), { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./foo.js"), { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
a(t(playgroundDir, "./foo.json"), null); | ||
a(t(playgroundDir, "./other"), resolve(`${ playgroundDir }/other.js`)); | ||
a(t(playgroundDir, "./other/"), resolve(`${ playgroundDir }/other/index.js`)); | ||
a(t(playgroundDir, "./samename"), resolve(`${ playgroundDir }/samename`)); | ||
a(t(playgroundDir, "./samename.js"), resolve(`${ playgroundDir }/samename.js`)); | ||
a(t(playgroundDir, "./samename.json"), resolve(`${ playgroundDir }/samename.json`)); | ||
a(t(playgroundDir, "./samename"), resolve(`${ playgroundDir }/samename`)); | ||
a(t(playgroundDir, "./dir"), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(playgroundDir, "./dir/lorem"), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(playgroundDir, "./dir/subdir/bar"), resolve(`${ playgroundDir }/dir/subdir/bar.js`)); | ||
a(t(`${ playgroundDir }/dir`, "."), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(`${ playgroundDir }/dir`, "./"), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(`${ playgroundDir }/dir`, "./lorem"), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(`${ playgroundDir }/dir`, "../other"), resolve(`${ playgroundDir }/other.js`)); | ||
a(t(`${ playgroundDir }/dir`, "../other/"), resolve(`${ playgroundDir }/other/index.js`)); | ||
a(t(`${ playgroundDir }/dir/subdir`, "../"), resolve(`${ playgroundDir }/dir/lorem.js`)); | ||
a(t(`${ playgroundDir }/dir/subdir`, "../../foo"), resolve(`${ playgroundDir }/foo.js`)); | ||
a.deep(t(playgroundDir, "./other"), { | ||
targetPath: resolve(`${ playgroundDir }/other.js`), | ||
realPath: resolve(`${ playgroundDir }/other.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./other/"), { | ||
targetPath: resolve(`${ playgroundDir }/other/index.js`), | ||
realPath: resolve(`${ playgroundDir }/other/index.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./samename"), { | ||
targetPath: resolve(`${ playgroundDir }/samename`), | ||
realPath: resolve(`${ playgroundDir }/samename`) | ||
}); | ||
a.deep(t(playgroundDir, "./samename.js"), { | ||
targetPath: resolve(`${ playgroundDir }/samename.js`), | ||
realPath: resolve(`${ playgroundDir }/samename.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./samename.json"), { | ||
targetPath: resolve(`${ playgroundDir }/samename.json`), | ||
realPath: resolve(`${ playgroundDir }/samename.json`) | ||
}); | ||
a.deep(t(playgroundDir, "./samename"), { | ||
targetPath: resolve(`${ playgroundDir }/samename`), | ||
realPath: resolve(`${ playgroundDir }/samename`) | ||
}); | ||
a.deep(t(playgroundDir, "./dir"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./dir/lorem"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./dir/subdir/bar"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/subdir/bar.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/subdir/bar.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir`, "."), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir`, "./"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir`, "./lorem"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir`, "../other"), { | ||
targetPath: resolve(`${ playgroundDir }/other.js`), | ||
realPath: resolve(`${ playgroundDir }/other.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir`, "../other/"), { | ||
targetPath: resolve(`${ playgroundDir }/other/index.js`), | ||
realPath: resolve(`${ playgroundDir }/other/index.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir/subdir`, "../"), { | ||
targetPath: resolve(`${ playgroundDir }/dir/lorem.js`), | ||
realPath: resolve(`${ playgroundDir }/dir/lorem.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/dir/subdir`, "../../foo"), { | ||
targetPath: resolve(`${ playgroundDir }/foo.js`), | ||
realPath: resolve(`${ playgroundDir }/foo.js`) | ||
}); | ||
a(t(playgroundDir, "outer"), resolve(`${ playgroundDir }/node_modules/outer/raz.js`)); | ||
a(t(playgroundDir, "outer/boo"), resolve(`${ playgroundDir }/node_modules/outer/boo.js`)); | ||
a.deep(t(playgroundDir, "outer"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`) | ||
}); | ||
a.deep(t(playgroundDir, "outer/boo"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`) | ||
}); | ||
a(t(playgroundDir, "outer/boo.json"), null); | ||
a(t(playgroundDir, "outer3"), resolve(`${ playgroundDir }/node_modules/outer3/index.js`)); | ||
a.deep(t(playgroundDir, "outer3"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
a(t(playgroundDir, "nested/elo"), null); | ||
a( | ||
t(`${ playgroundDir }/node_modules/outer`, "outer3"), | ||
resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
); | ||
a.deep(t(`${ playgroundDir }/node_modules/outer`, "outer3"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
a(t(`${ playgroundDir }/node_modules/outer`, "project/foo"), null); | ||
a( | ||
t(`${ playgroundDir }/node_modules/outer`, "nested/elo"), | ||
resolve(`${ playgroundDir }/node_modules/outer/node_modules/nested/elo.js`) | ||
); | ||
a.deep(t(`${ playgroundDir }/node_modules/outer`, "nested/elo"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/node_modules/nested/elo.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/node_modules/nested/elo.js`) | ||
}); | ||
a(t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "project/foo"), null); | ||
a( | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer"), | ||
resolve(`${ playgroundDir }/node_modules/outer/raz.js`) | ||
); | ||
a( | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer/boo"), | ||
resolve(`${ playgroundDir }/node_modules/outer/boo.js`) | ||
); | ||
a( | ||
t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer3"), | ||
resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
); | ||
a.deep(t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/raz.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer/boo"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer/boo.js`) | ||
}); | ||
a.deep(t(`${ playgroundDir }/node_modules/outer/node_modules/nested`, "outer3"), { | ||
targetPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`), | ||
realPath: resolve(`${ playgroundDir }/node_modules/outer3/index.js`) | ||
}); | ||
// Symlink tests | ||
return Promise.all([ | ||
setupFileLinks().then( | ||
() => { | ||
let testError, teardownPromise; | ||
try { | ||
a.deep(t(playgroundDir, "./valid-file-link"), { | ||
targetPath: resolve(`${ playgroundDir }/valid-file-link.js`), | ||
realPath: resolve(`${ playgroundDir }/file-link-target.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./deep-file-link"), { | ||
targetPath: resolve(`${ playgroundDir }/deep-file-link.js`), | ||
realPath: resolve(`${ playgroundDir }/deep-file-link-target.js`) | ||
}); | ||
a(t(playgroundDir, "./invalid-file-link"), null); | ||
a.deep(t(playgroundDir, "./invalid-file-link-with-a-fallback"), { | ||
targetPath: resolve( | ||
`${ playgroundDir }/invalid-file-link-with-a-fallback.json` | ||
), | ||
realPath: resolve( | ||
`${ playgroundDir }/invalid-file-link-with-a-fallback.json` | ||
) | ||
}); | ||
} catch (error) { | ||
testError = error; | ||
} finally { | ||
teardownPromise = teardownFileLinks(); | ||
} | ||
return teardownPromise.then(() => { if (testError) throw testError; }); | ||
}, | ||
error => { | ||
if (error.code === "EPERM") { | ||
process.stdout.write( | ||
"Warning: Could not test file symlinks due to not suffient " + | ||
"process permissions to create them\n" | ||
); | ||
return; | ||
} | ||
throw error; | ||
} | ||
), | ||
setupDirLinks().then(() => { | ||
let testError, teardownPromise; | ||
try { | ||
a.deep(t(playgroundDir, "./valid-dir-link"), { | ||
targetPath: resolve(`${ playgroundDir }/valid-dir-link/index.js`), | ||
realPath: resolve(`${ playgroundDir }/dir-link-target/index.js`) | ||
}); | ||
a.deep(t(playgroundDir, "./deep-dir-link"), { | ||
targetPath: resolve(`${ playgroundDir }/deep-dir-link/index.js`), | ||
realPath: resolve(`${ playgroundDir }/deep-dir-link-target/index.js`) | ||
}); | ||
a(t(playgroundDir, "./invalid-dir-link"), null); | ||
} catch (error) { | ||
testError = error; | ||
} finally { | ||
teardownPromise = teardownDirLinks(); | ||
} | ||
return teardownPromise.then(() => { if (testError) throw testError; }); | ||
}) | ||
]).then(noop); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51843
7
60
1057
144
27
Updateddeferred@^0.7.11
Updatedes5-ext@^0.10.51
Updatedfs2@^0.3.5
Updatedtype@^1.0.3