From 4c75a2700afd163280329b768a9e960b086f2124 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 29 Aug 2020 01:10:00 +0200 Subject: [PATCH 1/3] =?UTF-8?q?path:=20add=C2=A0`path/posix`=20and=C2=A0`p?= =?UTF-8?q?ath/win32`=20alias=C2=A0modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/api/path.md | 12 ++++++++++++ lib/path/posix.js | 3 +++ lib/path/win32.js | 3 +++ node.gyp | 2 ++ test/es-module/test-esm-path-posix.mjs | 6 ++++++ test/es-module/test-esm-path-win32.mjs | 6 ++++++ test/parallel/test-path-posix-exists.js | 6 ++++++ test/parallel/test-path-win32-exists.js | 6 ++++++ 8 files changed, 44 insertions(+) create mode 100644 lib/path/posix.js create mode 100644 lib/path/win32.js create mode 100644 test/es-module/test-esm-path-posix.mjs create mode 100644 test/es-module/test-esm-path-win32.mjs create mode 100644 test/parallel/test-path-posix-exists.js create mode 100644 test/parallel/test-path-win32-exists.js diff --git a/doc/api/path.md b/doc/api/path.md index c26a98e59c9d6d..15e3800c0f2dec 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` * {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)` * {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 00000000000000..aa8988d38481b2 --- /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 00000000000000..acb113aaae51ac --- /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 5a0b1ea112c2a7..a60e7f1e694bdc 100644 --- a/node.gyp +++ b/node.gyp @@ -72,6 +72,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 00000000000000..e58e0603180e8f --- /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 00000000000000..3b3304410774bd --- /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 00000000000000..dc12ed6daf027f --- /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 00000000000000..c9efa74dbd7d82 --- /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); From 4635b04b93c8534424f656bdbb63f82c2882a7e8 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:46:47 +0200 Subject: [PATCH 2/3] =?UTF-8?q?fixup!=20path:=20add=C2=A0`path/posix`=20an?= =?UTF-8?q?d=C2=A0`path/win32`=20alias=C2=A0modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rich Trott --- doc/api/path.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/path.md b/doc/api/path.md index 15e3800c0f2dec..ef3703c675db55 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -437,7 +437,7 @@ added: v0.11.15 changes: - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/34962 - description: Exposed as `require('path/posix')` + description: Exposed as `require('path/posix')`. --> * {Object} From c980bd82a1b39207436723f8618cb46fa4d6457f Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Mon, 19 Oct 2020 15:08:05 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fixup!=20path:=20add=C2=A0`path/posix`=20an?= =?UTF-8?q?d=C2=A0`path/win32`=20alias=C2=A0modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rich Trott --- doc/api/path.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/path.md b/doc/api/path.md index ef3703c675db55..36c281b772e1af 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -577,7 +577,7 @@ added: v0.11.15 changes: - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/34962 - description: Exposed as `require('path/win32')` + description: Exposed as `require('path/win32')`. --> * {Object}