Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path: add path/posix and path/win32 alias modules #34962

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/api/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,19 @@ 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}

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
Expand Down Expand Up @@ -568,13 +574,19 @@ 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')`
ExE-Boss marked this conversation as resolved.
Show resolved Hide resolved
-->

* {Object}

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
Expand Down
3 changes: 3 additions & 0 deletions lib/path/posix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('path').posix;
ExE-Boss marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions lib/path/win32.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('path').win32;
2 changes: 2 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions test/es-module/test-esm-path-posix.mjs
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions test/es-module/test-esm-path-win32.mjs
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions test/parallel/test-path-posix-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');

assert.strictEqual(require('path/posix'), require('path').posix);
6 changes: 6 additions & 0 deletions test/parallel/test-path-win32-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');

assert.strictEqual(require('path/win32'), require('path').win32);