Skip to content

Commit 85c85d3

Browse files
ExE-Bosscodebytere
authored andcommitted
path: add path/posix and path/win32 alias modules
Refs: #31553 Refs: #32953 Refs: #33950 Refs: #34001 Refs: #34002 Refs: #34055 PR-URL: #34962 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent 3dd0637 commit 85c85d3

8 files changed

+44
-0
lines changed

doc/api/path.md

+12
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,19 @@ A [`TypeError`][] is thrown if `path` is not a string.
434434
## `path.posix`
435435
<!-- YAML
436436
added: v0.11.15
437+
changes:
438+
- version: REPLACEME
439+
pr-url: https://github.com/nodejs/node/pull/34962
440+
description: Exposed as `require('path/posix')`.
437441
-->
438442

439443
* {Object}
440444

441445
The `path.posix` property provides access to POSIX specific implementations
442446
of the `path` methods.
443447

448+
The API is accessible via `require('path').posix` or `require('path/posix')`.
449+
444450
## `path.relative(from, to)`
445451
<!-- YAML
446452
added: v0.5.0
@@ -568,13 +574,19 @@ method is non-operational and always returns `path` without modifications.
568574
## `path.win32`
569575
<!-- YAML
570576
added: v0.11.15
577+
changes:
578+
- version: REPLACEME
579+
pr-url: https://github.com/nodejs/node/pull/34962
580+
description: Exposed as `require('path/win32')`.
571581
-->
572582

573583
* {Object}
574584

575585
The `path.win32` property provides access to Windows-specific implementations
576586
of the `path` methods.
577587

588+
The API is accessible via `require('path').win32` or `require('path/win32')`.
589+
578590
[MSDN-Rel-Path]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths
579591
[`TypeError`]: errors.md#errors_class_typeerror
580592
[`path.parse()`]: #path_path_parse_path

lib/path/posix.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require('path').posix;

lib/path/win32.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require('path').win32;

node.gyp

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
'lib/net.js',
7474
'lib/os.js',
7575
'lib/path.js',
76+
'lib/path/posix.js',
77+
'lib/path/win32.js',
7678
'lib/perf_hooks.js',
7779
'lib/process.js',
7880
'lib/punycode.js',
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import '../common/index.mjs';
2+
import assert from 'assert';
3+
import { posix } from 'path';
4+
import pathPosix from 'path/posix';
5+
6+
assert.strictEqual(pathPosix, posix);
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import '../common/index.mjs';
2+
import assert from 'assert';
3+
import { win32 } from 'path';
4+
import pathWin32 from 'path/win32';
5+
6+
assert.strictEqual(pathWin32, win32);
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
assert.strictEqual(require('path/posix'), require('path').posix);
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
assert.strictEqual(require('path/win32'), require('path').win32);

0 commit comments

Comments
 (0)