Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorExE Boss <3889017+ExE-Boss@users.noreply.github.com>2020-08-29 02:10:00 +0300
committerShelley Vohr <shelley.vohr@gmail.com>2020-11-22 21:18:56 +0300
commit85c85d368a6cdac67d2da1b0f241501accafe05d (patch)
treedb896af72359da317afc6bc3aee06b082dfbd4ff
parent3dd06375d4768be7e136142bb667d5034cd8717d (diff)
path: add `path/posix` and `path/win32` alias modules
Refs: https://github.com/nodejs/node/pull/31553 Refs: https://github.com/nodejs/node/pull/32953 Refs: https://github.com/nodejs/node/pull/33950 Refs: https://github.com/nodejs/node/pull/34001 Refs: https://github.com/nodejs/node/pull/34002 Refs: https://github.com/nodejs/node/pull/34055 PR-URL: https://github.com/nodejs/node/pull/34962 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
-rw-r--r--doc/api/path.md12
-rw-r--r--lib/path/posix.js3
-rw-r--r--lib/path/win32.js3
-rw-r--r--node.gyp2
-rw-r--r--test/es-module/test-esm-path-posix.mjs6
-rw-r--r--test/es-module/test-esm-path-win32.mjs6
-rw-r--r--test/parallel/test-path-posix-exists.js6
-rw-r--r--test/parallel/test-path-win32-exists.js6
8 files changed, 44 insertions, 0 deletions
diff --git a/doc/api/path.md b/doc/api/path.md
index c26a98e59c9..36c281b772e 100644
--- a/doc/api/path.md
+++ b/doc/api/path.md
@@ -434,6 +434,10 @@ A [`TypeError`][] is thrown if `path` is not a string.
## `path.posix`
<!-- YAML
added: v0.11.15
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/34962
+ description: Exposed as `require('path/posix')`.
-->
* {Object}
@@ -441,6 +445,8 @@ added: v0.11.15
The `path.posix` property provides access to POSIX specific implementations
of the `path` methods.
+The API is accessible via `require('path').posix` or `require('path/posix')`.
+
## `path.relative(from, to)`
<!-- YAML
added: v0.5.0
@@ -568,6 +574,10 @@ method is non-operational and always returns `path` without modifications.
## `path.win32`
<!-- YAML
added: v0.11.15
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/34962
+ description: Exposed as `require('path/win32')`.
-->
* {Object}
@@ -575,6 +585,8 @@ added: v0.11.15
The `path.win32` property provides access to Windows-specific implementations
of the `path` methods.
+The API is accessible via `require('path').win32` or `require('path/win32')`.
+
[MSDN-Rel-Path]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths
[`TypeError`]: errors.md#errors_class_typeerror
[`path.parse()`]: #path_path_parse_path
diff --git a/lib/path/posix.js b/lib/path/posix.js
new file mode 100644
index 00000000000..aa8988d3848
--- /dev/null
+++ b/lib/path/posix.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = require('path').posix;
diff --git a/lib/path/win32.js b/lib/path/win32.js
new file mode 100644
index 00000000000..acb113aaae5
--- /dev/null
+++ b/lib/path/win32.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = require('path').win32;
diff --git a/node.gyp b/node.gyp
index d4dc83d257b..38cf71309f8 100644
--- a/node.gyp
+++ b/node.gyp
@@ -73,6 +73,8 @@
'lib/net.js',
'lib/os.js',
'lib/path.js',
+ 'lib/path/posix.js',
+ 'lib/path/win32.js',
'lib/perf_hooks.js',
'lib/process.js',
'lib/punycode.js',
diff --git a/test/es-module/test-esm-path-posix.mjs b/test/es-module/test-esm-path-posix.mjs
new file mode 100644
index 00000000000..e58e0603180
--- /dev/null
+++ b/test/es-module/test-esm-path-posix.mjs
@@ -0,0 +1,6 @@
+import '../common/index.mjs';
+import assert from 'assert';
+import { posix } from 'path';
+import pathPosix from 'path/posix';
+
+assert.strictEqual(pathPosix, posix);
diff --git a/test/es-module/test-esm-path-win32.mjs b/test/es-module/test-esm-path-win32.mjs
new file mode 100644
index 00000000000..3b330441077
--- /dev/null
+++ b/test/es-module/test-esm-path-win32.mjs
@@ -0,0 +1,6 @@
+import '../common/index.mjs';
+import assert from 'assert';
+import { win32 } from 'path';
+import pathWin32 from 'path/win32';
+
+assert.strictEqual(pathWin32, win32);
diff --git a/test/parallel/test-path-posix-exists.js b/test/parallel/test-path-posix-exists.js
new file mode 100644
index 00000000000..dc12ed6daf0
--- /dev/null
+++ b/test/parallel/test-path-posix-exists.js
@@ -0,0 +1,6 @@
+'use strict';
+
+require('../common');
+const assert = require('assert');
+
+assert.strictEqual(require('path/posix'), require('path').posix);
diff --git a/test/parallel/test-path-win32-exists.js b/test/parallel/test-path-win32-exists.js
new file mode 100644
index 00000000000..c9efa74dbd7
--- /dev/null
+++ b/test/parallel/test-path-win32-exists.js
@@ -0,0 +1,6 @@
+'use strict';
+
+require('../common');
+const assert = require('assert');
+
+assert.strictEqual(require('path/win32'), require('path').win32);