@ohos-ports/stdlib-process 0.0.0-stage → 0.4.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +220 -2
  4. package/SECURITY.md +5 -0
  5. package/argv/README.md +104 -0
  6. package/argv/docs/repl.txt +22 -0
  7. package/argv/docs/types/index.d.ts +33 -0
  8. package/argv/docs/types/test.ts +28 -0
  9. package/argv/lib/browser.js +28 -0
  10. package/argv/lib/index.js +40 -0
  11. package/argv/lib/main.js +43 -0
  12. package/argv/package.json +70 -0
  13. package/chdir/README.md +124 -0
  14. package/chdir/docs/repl.txt +25 -0
  15. package/chdir/docs/types/index.d.ts +42 -0
  16. package/chdir/docs/types/test.ts +45 -0
  17. package/chdir/lib/index.js +42 -0
  18. package/chdir/lib/main.js +52 -0
  19. package/chdir/lib/polyfill.js +42 -0
  20. package/chdir/package.json +73 -0
  21. package/cwd/README.md +140 -0
  22. package/cwd/bin/cli +60 -0
  23. package/cwd/docs/repl.txt +17 -0
  24. package/cwd/docs/types/index.d.ts +35 -0
  25. package/cwd/docs/types/test.ts +33 -0
  26. package/cwd/docs/usage.txt +8 -0
  27. package/cwd/etc/cli_opts.json +14 -0
  28. package/cwd/lib/index.js +40 -0
  29. package/cwd/lib/main.js +44 -0
  30. package/cwd/lib/polyfill.js +40 -0
  31. package/cwd/package.json +75 -0
  32. package/docs/types/index.d.ts +225 -0
  33. package/env/README.md +104 -0
  34. package/env/docs/repl.txt +12 -0
  35. package/env/docs/types/index.d.ts +32 -0
  36. package/env/docs/types/test.ts +28 -0
  37. package/env/lib/browser.js +28 -0
  38. package/env/lib/index.js +39 -0
  39. package/env/lib/main.js +42 -0
  40. package/env/package.json +72 -0
  41. package/exec-path/README.md +90 -0
  42. package/exec-path/docs/repl.txt +13 -0
  43. package/exec-path/docs/types/index.d.ts +36 -0
  44. package/exec-path/docs/types/test.ts +28 -0
  45. package/exec-path/lib/browser.js +23 -0
  46. package/exec-path/lib/index.js +55 -0
  47. package/exec-path/lib/main.js +46 -0
  48. package/exec-path/package.json +72 -0
  49. package/getegid/README.md +107 -0
  50. package/getegid/docs/repl.txt +20 -0
  51. package/getegid/docs/types/index.d.ts +38 -0
  52. package/getegid/docs/types/test.ts +33 -0
  53. package/getegid/lib/index.js +39 -0
  54. package/getegid/lib/main.js +45 -0
  55. package/getegid/lib/native.js +44 -0
  56. package/getegid/lib/polyfill.js +40 -0
  57. package/getegid/package.json +76 -0
  58. package/geteuid/README.md +111 -0
  59. package/geteuid/docs/repl.txt +20 -0
  60. package/geteuid/docs/types/index.d.ts +38 -0
  61. package/geteuid/docs/types/test.ts +33 -0
  62. package/geteuid/lib/index.js +39 -0
  63. package/geteuid/lib/main.js +45 -0
  64. package/geteuid/lib/native.js +44 -0
  65. package/geteuid/lib/polyfill.js +40 -0
  66. package/geteuid/package.json +76 -0
  67. package/getgid/README.md +107 -0
  68. package/getgid/docs/repl.txt +19 -0
  69. package/getgid/docs/types/index.d.ts +38 -0
  70. package/getgid/docs/types/test.ts +33 -0
  71. package/getgid/lib/index.js +39 -0
  72. package/getgid/lib/main.js +45 -0
  73. package/getgid/lib/native.js +44 -0
  74. package/getgid/lib/polyfill.js +40 -0
  75. package/getgid/package.json +75 -0
  76. package/getuid/README.md +111 -0
  77. package/getuid/docs/repl.txt +19 -0
  78. package/getuid/docs/types/index.d.ts +38 -0
  79. package/getuid/docs/types/test.ts +33 -0
  80. package/getuid/lib/index.js +39 -0
  81. package/getuid/lib/main.js +45 -0
  82. package/getuid/lib/native.js +44 -0
  83. package/getuid/lib/polyfill.js +40 -0
  84. package/getuid/package.json +75 -0
  85. package/lib/index.js +150 -0
  86. package/node-version/README.md +135 -0
  87. package/node-version/bin/cli +60 -0
  88. package/node-version/docs/repl.txt +12 -0
  89. package/node-version/docs/types/index.d.ts +42 -0
  90. package/node-version/docs/types/test.ts +28 -0
  91. package/node-version/docs/usage.txt +8 -0
  92. package/node-version/etc/cli_opts.json +14 -0
  93. package/node-version/lib/browser.js +23 -0
  94. package/node-version/lib/index.js +60 -0
  95. package/node-version/lib/main.js +43 -0
  96. package/node-version/lib/process.js +28 -0
  97. package/node-version/package.json +73 -0
  98. package/package.json +121 -4
  99. package/read-stdin/README.md +152 -0
  100. package/read-stdin/docs/types/index.d.ts +108 -0
  101. package/read-stdin/docs/types/test.ts +73 -0
  102. package/read-stdin/lib/browser.js +66 -0
  103. package/read-stdin/lib/index.js +47 -0
  104. package/read-stdin/lib/main.js +159 -0
  105. package/read-stdin/package.json +67 -0
  106. package/umask/README.md +281 -0
  107. package/umask/bin/cli +84 -0
  108. package/umask/docs/repl.txt +133 -0
  109. package/umask/docs/types/index.d.ts +69 -0
  110. package/umask/docs/types/test.ts +62 -0
  111. package/umask/docs/usage.txt +9 -0
  112. package/umask/etc/cli_opts.json +22 -0
  113. package/umask/lib/browser.js +133 -0
  114. package/umask/lib/from_symbolic.js +218 -0
  115. package/umask/lib/index.js +40 -0
  116. package/umask/lib/main.js +128 -0
  117. package/umask/lib/octal_codes.json +10 -0
  118. package/umask/lib/to_symbolic.js +57 -0
  119. package/umask/package.json +78 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var proc = require( 'process' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * An array containing command-line arguments passed when launching the calling process.
30
+ *
31
+ * @name ARGV
32
+ * @type {StringArray}
33
+ *
34
+ * @example
35
+ * console.log( ARGV );
36
+ * // => [...]
37
+ */
38
+ var ARGV = proc.argv;
39
+
40
+
41
+ // EXPORTS //
42
+
43
+ module.exports = ARGV;
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@stdlib/process/argv",
3
+ "version": "0.0.0",
4
+ "description": "Array containing command-line arguments passed when launching the calling process.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "browser": {
18
+ "./lib": "./lib/browser.js",
19
+ "process": "process/"
20
+ },
21
+ "directories": {
22
+ "doc": "./docs",
23
+ "example": "./examples",
24
+ "lib": "./lib",
25
+ "test": "./test"
26
+ },
27
+ "types": "./docs/types",
28
+ "scripts": {},
29
+ "homepage": "https://github.com/stdlib-js/stdlib",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git://github.com/stdlib-js/stdlib.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/stdlib-js/stdlib/issues"
36
+ },
37
+ "dependencies": {},
38
+ "devDependencies": {},
39
+ "engines": {
40
+ "node": ">=0.10.0",
41
+ "npm": ">2.7.0"
42
+ },
43
+ "os": [
44
+ "aix",
45
+ "darwin",
46
+ "freebsd",
47
+ "linux",
48
+ "macos",
49
+ "openbsd",
50
+ "sunos",
51
+ "win32",
52
+ "windows",
53
+ "openharmony"
54
+ ],
55
+ "keywords": [
56
+ "stdlib",
57
+ "stdutils",
58
+ "stdutil",
59
+ "utilities",
60
+ "utility",
61
+ "utils",
62
+ "util",
63
+ "process",
64
+ "argv",
65
+ "arguments",
66
+ "args",
67
+ "command-line",
68
+ "cli"
69
+ ]
70
+ }
@@ -0,0 +1,124 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+ # chdir
22
+
23
+ > Change the current working directory.
24
+
25
+ <section class="usage">
26
+
27
+ ## Usage
28
+
29
+ ```javascript
30
+ var chdir = require( '@stdlib/process/chdir' );
31
+ ```
32
+
33
+ #### chdir( path )
34
+
35
+ Changes the current working directory to the specified `path`.
36
+
37
+ <!-- run-disable -->
38
+
39
+ ```javascript
40
+ var err = chdir( '/foo/bar' );
41
+ ```
42
+
43
+ If the function encounters an error when attempting to change the working directory, the function returns an `error`; otherwise, the function returns `null`.
44
+
45
+ </section>
46
+
47
+ <!-- /.usage -->
48
+
49
+ <section class="notes">
50
+
51
+ ## Notes
52
+
53
+ - See [chdir(2)][chdir].
54
+
55
+ </section>
56
+
57
+ <!-- /.notes -->
58
+
59
+ <section class="examples">
60
+
61
+ ## Examples
62
+
63
+ <!-- eslint no-undef: "error" -->
64
+
65
+ ```javascript
66
+ var cwd = require( '@stdlib/process/cwd' );
67
+ var chdir = require( '@stdlib/process/chdir' );
68
+
69
+ // Print the current working directory:
70
+ var dir = cwd();
71
+ console.log( dir );
72
+
73
+ // Change the current working directory to the directory of this file:
74
+ var err = chdir( __dirname );
75
+ if ( err ) {
76
+ console.error( err.message );
77
+ }
78
+
79
+ // Print the current working directory:
80
+ console.log( cwd() );
81
+
82
+ // Change the current working directory back to the original directory:
83
+ err = chdir( dir );
84
+ if ( err ) {
85
+ console.error( err.message );
86
+ }
87
+
88
+ // Print the current working directory:
89
+ console.log( cwd() );
90
+ ```
91
+
92
+ </section>
93
+
94
+ <!-- /.examples -->
95
+
96
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
97
+
98
+ <section class="related">
99
+
100
+ * * *
101
+
102
+ ## See Also
103
+
104
+ - <span class="package-name">[`@stdlib/process/cwd`][@stdlib/process/cwd]</span><span class="delimiter">: </span><span class="description">return the current working directory.</span>
105
+
106
+ </section>
107
+
108
+ <!-- /.related -->
109
+
110
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
111
+
112
+ <section class="links">
113
+
114
+ [chdir]: http://man7.org/linux/man-pages/man2/chdir.2.html
115
+
116
+ <!-- <related-links> -->
117
+
118
+ [@stdlib/process/cwd]: https://github.com/stdlib-js/process/tree/main/cwd
119
+
120
+ <!-- </related-links> -->
121
+
122
+ </section>
123
+
124
+ <!-- /.links -->
@@ -0,0 +1,25 @@
1
+
2
+ {{alias}}( path )
3
+ Changes the current working directory.
4
+
5
+ If unable to set the current working directory (e.g., due to a non-existent
6
+ path), the function returns an error; otherwise, the function returns
7
+ `null`.
8
+
9
+ Parameters
10
+ ----------
11
+ path: string
12
+ Desired working directory.
13
+
14
+ Returns
15
+ -------
16
+ err: Error|null
17
+ Error object or null.
18
+
19
+ Examples
20
+ --------
21
+ > var err = {{alias}}( '/path/to/current/working/directory' )
22
+
23
+ See Also
24
+ --------
25
+
@@ -0,0 +1,42 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2019 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /**
22
+ * Changes the current working directory.
23
+ *
24
+ * ## Notes
25
+ *
26
+ * - If unable to set the current working directory (e.g., due to a non-existent path), the function returns an error; otherwise, the function returns `null`.
27
+ *
28
+ * @param path - desired working directory
29
+ * @returns error object or `null`
30
+ *
31
+ * @example
32
+ * var err = chdir( __dirname );
33
+ * if ( err ) {
34
+ * throw err;
35
+ * }
36
+ */
37
+ declare function chdir( path: string ): Error | null;
38
+
39
+
40
+ // EXPORTS //
41
+
42
+ export = chdir;
@@ -0,0 +1,45 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2019 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import chdir = require( './index' );
20
+
21
+
22
+ // TESTS //
23
+
24
+ // The function returns null or an error...
25
+ {
26
+ chdir( './' ); // $ExpectType Error | null
27
+ chdir( 'kjflajflsda/bkadlfjadlfksabldjkfklajsf/dkfaljsf' ); // $ExpectType Error | null
28
+ }
29
+
30
+ // The compiler throws an error if the function is provided a value other than a string...
31
+ {
32
+ chdir( true ); // $ExpectError
33
+ chdir( false ); // $ExpectError
34
+ chdir( null ); // $ExpectError
35
+ chdir( undefined ); // $ExpectError
36
+ chdir( 5 ); // $ExpectError
37
+ chdir( [] ); // $ExpectError
38
+ chdir( {} ); // $ExpectError
39
+ chdir( ( x: number ): number => x ); // $ExpectError
40
+ }
41
+
42
+ // The compiler throws an error if the function is provided insufficient arguments...
43
+ {
44
+ chdir(); // $ExpectError
45
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ /**
22
+ * Change the current working directory.
23
+ *
24
+ * @module @stdlib/process/chdir
25
+ *
26
+ * @example
27
+ * var chdir = require( '@ohos-ports/stdlib-process/chdir' );
28
+ *
29
+ * var err = chdir( __dirname );
30
+ * if ( err ) {
31
+ * throw err;
32
+ * }
33
+ */
34
+
35
+ // MODULES //
36
+
37
+ var main = require( './main.js' );
38
+
39
+
40
+ // EXPORTS //
41
+
42
+ module.exports = main;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var proc = require( 'process' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Changes the current working directory.
30
+ *
31
+ * @param {string} path - desired working directory
32
+ * @returns {(Error|null)} error object
33
+ *
34
+ * @example
35
+ * var err = chdir( __dirname );
36
+ * if ( err ) {
37
+ * throw err;
38
+ * }
39
+ */
40
+ function chdir( path ) {
41
+ try {
42
+ proc.chdir( path );
43
+ } catch ( err ) {
44
+ return err;
45
+ }
46
+ return null;
47
+ }
48
+
49
+
50
+ // EXPORTS //
51
+
52
+ module.exports = chdir;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MAIN //
22
+
23
+ /**
24
+ * Polyfill for changing the current working directory in environments having no native support for doing so.
25
+ *
26
+ * @param {string} path - desired working directory
27
+ * @returns {Error} error object
28
+ *
29
+ * @example
30
+ * var err = chdir( __dirname );
31
+ * if ( err ) {
32
+ * console.error( err.message );
33
+ * }
34
+ */
35
+ function chdir() {
36
+ return new Error( 'invalid operation. A browser environment has no support for changing the current working directory.' );
37
+ }
38
+
39
+
40
+ // EXPORTS //
41
+
42
+ module.exports = chdir;
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@stdlib/process/chdir",
3
+ "version": "0.0.0",
4
+ "description": "Change the current working directory.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "browser": {
18
+ "./lib": "./lib/polyfill.js",
19
+ "process": "process/"
20
+ },
21
+ "directories": {
22
+ "benchmark": "./benchmark",
23
+ "doc": "./docs",
24
+ "example": "./examples",
25
+ "lib": "./lib",
26
+ "test": "./test"
27
+ },
28
+ "types": "./docs/types",
29
+ "scripts": {},
30
+ "homepage": "https://github.com/stdlib-js/stdlib",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git://github.com/stdlib-js/stdlib.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/stdlib-js/stdlib/issues"
37
+ },
38
+ "dependencies": {},
39
+ "devDependencies": {},
40
+ "engines": {
41
+ "node": ">=0.10.0",
42
+ "npm": ">2.7.0"
43
+ },
44
+ "os": [
45
+ "aix",
46
+ "darwin",
47
+ "freebsd",
48
+ "linux",
49
+ "macos",
50
+ "openbsd",
51
+ "sunos",
52
+ "win32",
53
+ "windows",
54
+ "openharmony"
55
+ ],
56
+ "keywords": [
57
+ "stdlib",
58
+ "stdutils",
59
+ "stdutil",
60
+ "utilities",
61
+ "utility",
62
+ "utils",
63
+ "util",
64
+ "working",
65
+ "directory",
66
+ "process",
67
+ "dir",
68
+ "cwd",
69
+ "pwd",
70
+ "path",
71
+ "chdir"
72
+ ]
73
+ }
package/cwd/README.md ADDED
@@ -0,0 +1,140 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+ # cwd
22
+
23
+ > Return the current working directory.
24
+
25
+ <section class="usage">
26
+
27
+ ## Usage
28
+
29
+ ```javascript
30
+ var cwd = require( '@stdlib/process/cwd' );
31
+ ```
32
+
33
+ #### cwd()
34
+
35
+ Returns the current working directory.
36
+
37
+ ```javascript
38
+ var dir = cwd();
39
+ // e.g., returns '/path/to/current/working/directory'
40
+ ```
41
+
42
+ </section>
43
+
44
+ <!-- /.usage -->
45
+
46
+ <section class="notes">
47
+
48
+ ## Notes
49
+
50
+ - In browser environments, the current working directory is always equal to `'/'`.
51
+
52
+ </section>
53
+
54
+ <!-- /.notes -->
55
+
56
+ <section class="examples">
57
+
58
+ ## Examples
59
+
60
+ <!-- eslint no-undef: "error" -->
61
+
62
+ ```javascript
63
+ var PATH_SEP = require( '@stdlib/constants/path/sep' );
64
+ var cwd = require( '@stdlib/process/cwd' );
65
+
66
+ var parts = cwd().split( PATH_SEP );
67
+ console.log( parts );
68
+ ```
69
+
70
+ </section>
71
+
72
+ <!-- /.examples -->
73
+
74
+ * * *
75
+
76
+ <section class="cli">
77
+
78
+ ## CLI
79
+
80
+ <section class="usage">
81
+
82
+ ### Usage
83
+
84
+ ```text
85
+ Usage: cwd [options]
86
+
87
+ Options:
88
+
89
+ -h, --help Print this message.
90
+ -V, --version Print the package version.
91
+ ```
92
+
93
+ </section>
94
+
95
+ <!-- /.usage -->
96
+
97
+ <section class="examples">
98
+
99
+ ### Examples
100
+
101
+ ```bash
102
+ $ cwd
103
+ /path/to/current/working/directory
104
+ ```
105
+
106
+ </section>
107
+
108
+ <!-- /.examples -->
109
+
110
+ </section>
111
+
112
+ <!-- /.cli -->
113
+
114
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
115
+
116
+ <section class="related">
117
+
118
+ * * *
119
+
120
+ ## See Also
121
+
122
+ - <span class="package-name">[`@stdlib/process/chdir`][@stdlib/process/chdir]</span><span class="delimiter">: </span><span class="description">change the current working directory.</span>
123
+
124
+ </section>
125
+
126
+ <!-- /.related -->
127
+
128
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
129
+
130
+ <section class="links">
131
+
132
+ <!-- <related-links> -->
133
+
134
+ [@stdlib/process/chdir]: https://github.com/stdlib-js/process/tree/main/chdir
135
+
136
+ <!-- </related-links> -->
137
+
138
+ </section>
139
+
140
+ <!-- /.links -->