@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.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +220 -2
- package/SECURITY.md +5 -0
- package/argv/README.md +104 -0
- package/argv/docs/repl.txt +22 -0
- package/argv/docs/types/index.d.ts +33 -0
- package/argv/docs/types/test.ts +28 -0
- package/argv/lib/browser.js +28 -0
- package/argv/lib/index.js +40 -0
- package/argv/lib/main.js +43 -0
- package/argv/package.json +70 -0
- package/chdir/README.md +124 -0
- package/chdir/docs/repl.txt +25 -0
- package/chdir/docs/types/index.d.ts +42 -0
- package/chdir/docs/types/test.ts +45 -0
- package/chdir/lib/index.js +42 -0
- package/chdir/lib/main.js +52 -0
- package/chdir/lib/polyfill.js +42 -0
- package/chdir/package.json +73 -0
- package/cwd/README.md +140 -0
- package/cwd/bin/cli +60 -0
- package/cwd/docs/repl.txt +17 -0
- package/cwd/docs/types/index.d.ts +35 -0
- package/cwd/docs/types/test.ts +33 -0
- package/cwd/docs/usage.txt +8 -0
- package/cwd/etc/cli_opts.json +14 -0
- package/cwd/lib/index.js +40 -0
- package/cwd/lib/main.js +44 -0
- package/cwd/lib/polyfill.js +40 -0
- package/cwd/package.json +75 -0
- package/docs/types/index.d.ts +225 -0
- package/env/README.md +104 -0
- package/env/docs/repl.txt +12 -0
- package/env/docs/types/index.d.ts +32 -0
- package/env/docs/types/test.ts +28 -0
- package/env/lib/browser.js +28 -0
- package/env/lib/index.js +39 -0
- package/env/lib/main.js +42 -0
- package/env/package.json +72 -0
- package/exec-path/README.md +90 -0
- package/exec-path/docs/repl.txt +13 -0
- package/exec-path/docs/types/index.d.ts +36 -0
- package/exec-path/docs/types/test.ts +28 -0
- package/exec-path/lib/browser.js +23 -0
- package/exec-path/lib/index.js +55 -0
- package/exec-path/lib/main.js +46 -0
- package/exec-path/package.json +72 -0
- package/getegid/README.md +107 -0
- package/getegid/docs/repl.txt +20 -0
- package/getegid/docs/types/index.d.ts +38 -0
- package/getegid/docs/types/test.ts +33 -0
- package/getegid/lib/index.js +39 -0
- package/getegid/lib/main.js +45 -0
- package/getegid/lib/native.js +44 -0
- package/getegid/lib/polyfill.js +40 -0
- package/getegid/package.json +76 -0
- package/geteuid/README.md +111 -0
- package/geteuid/docs/repl.txt +20 -0
- package/geteuid/docs/types/index.d.ts +38 -0
- package/geteuid/docs/types/test.ts +33 -0
- package/geteuid/lib/index.js +39 -0
- package/geteuid/lib/main.js +45 -0
- package/geteuid/lib/native.js +44 -0
- package/geteuid/lib/polyfill.js +40 -0
- package/geteuid/package.json +76 -0
- package/getgid/README.md +107 -0
- package/getgid/docs/repl.txt +19 -0
- package/getgid/docs/types/index.d.ts +38 -0
- package/getgid/docs/types/test.ts +33 -0
- package/getgid/lib/index.js +39 -0
- package/getgid/lib/main.js +45 -0
- package/getgid/lib/native.js +44 -0
- package/getgid/lib/polyfill.js +40 -0
- package/getgid/package.json +75 -0
- package/getuid/README.md +111 -0
- package/getuid/docs/repl.txt +19 -0
- package/getuid/docs/types/index.d.ts +38 -0
- package/getuid/docs/types/test.ts +33 -0
- package/getuid/lib/index.js +39 -0
- package/getuid/lib/main.js +45 -0
- package/getuid/lib/native.js +44 -0
- package/getuid/lib/polyfill.js +40 -0
- package/getuid/package.json +75 -0
- package/lib/index.js +150 -0
- package/node-version/README.md +135 -0
- package/node-version/bin/cli +60 -0
- package/node-version/docs/repl.txt +12 -0
- package/node-version/docs/types/index.d.ts +42 -0
- package/node-version/docs/types/test.ts +28 -0
- package/node-version/docs/usage.txt +8 -0
- package/node-version/etc/cli_opts.json +14 -0
- package/node-version/lib/browser.js +23 -0
- package/node-version/lib/index.js +60 -0
- package/node-version/lib/main.js +43 -0
- package/node-version/lib/process.js +28 -0
- package/node-version/package.json +73 -0
- package/package.json +121 -4
- package/read-stdin/README.md +152 -0
- package/read-stdin/docs/types/index.d.ts +108 -0
- package/read-stdin/docs/types/test.ts +73 -0
- package/read-stdin/lib/browser.js +66 -0
- package/read-stdin/lib/index.js +47 -0
- package/read-stdin/lib/main.js +159 -0
- package/read-stdin/package.json +67 -0
- package/umask/README.md +281 -0
- package/umask/bin/cli +84 -0
- package/umask/docs/repl.txt +133 -0
- package/umask/docs/types/index.d.ts +69 -0
- package/umask/docs/types/test.ts +62 -0
- package/umask/docs/usage.txt +9 -0
- package/umask/etc/cli_opts.json +22 -0
- package/umask/lib/browser.js +133 -0
- package/umask/lib/from_symbolic.js +218 -0
- package/umask/lib/index.js +40 -0
- package/umask/lib/main.js +128 -0
- package/umask/lib/octal_codes.json +10 -0
- package/umask/lib/to_symbolic.js +57 -0
- package/umask/package.json +78 -0
package/cwd/bin/cli
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2018 The Stdlib Authors.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
'use strict';
|
|
22
|
+
|
|
23
|
+
// MODULES //
|
|
24
|
+
|
|
25
|
+
var resolve = require( 'path' ).resolve;
|
|
26
|
+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
|
|
27
|
+
var CLI = require( '@stdlib/cli/ctor' );
|
|
28
|
+
var cwd = require( './../lib' );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// MAIN //
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Main execution sequence.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
function main() {
|
|
39
|
+
var flags;
|
|
40
|
+
var cli;
|
|
41
|
+
|
|
42
|
+
// Create a command-line interface:
|
|
43
|
+
cli = new CLI({
|
|
44
|
+
'pkg': require( './../package.json' ),
|
|
45
|
+
'options': require( './../etc/cli_opts.json' ),
|
|
46
|
+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
|
|
47
|
+
'encoding': 'utf8'
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Get any provided command-line options:
|
|
52
|
+
flags = cli.flags();
|
|
53
|
+
if ( flags.help || flags.version ) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log( cwd() ); // eslint-disable-line no-console
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
main();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}()
|
|
3
|
+
Returns the current working directory.
|
|
4
|
+
|
|
5
|
+
Returns
|
|
6
|
+
-------
|
|
7
|
+
path: string
|
|
8
|
+
Current working directory of the process.
|
|
9
|
+
|
|
10
|
+
Examples
|
|
11
|
+
--------
|
|
12
|
+
> var dir = {{alias}}()
|
|
13
|
+
'/path/to/current/working/directory'
|
|
14
|
+
|
|
15
|
+
See Also
|
|
16
|
+
--------
|
|
17
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
* Returns the current working directory of the process.
|
|
23
|
+
*
|
|
24
|
+
* @returns current working directory of the process
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var dir = cwd();
|
|
28
|
+
* // returns '/path/to/current/working/directory'
|
|
29
|
+
*/
|
|
30
|
+
declare function cwd(): string;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// EXPORTS //
|
|
34
|
+
|
|
35
|
+
export = cwd;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 cwd = require( './index' );
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// TESTS //
|
|
23
|
+
|
|
24
|
+
// The function returns a string...
|
|
25
|
+
{
|
|
26
|
+
cwd(); // $ExpectType string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The compiler throws an error if the function is provided arguments...
|
|
30
|
+
{
|
|
31
|
+
cwd( true ); // $ExpectError
|
|
32
|
+
cwd( [], 123 ); // $ExpectError
|
|
33
|
+
}
|
package/cwd/lib/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* Return the current working directory of the process.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/process/cwd
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var cwd = require( '@ohos-ports/stdlib-process/cwd' );
|
|
28
|
+
*
|
|
29
|
+
* var dir = cwd();
|
|
30
|
+
* // returns '/path/to/current/working/directory'
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// MODULES //
|
|
34
|
+
|
|
35
|
+
var main = require( './main.js' );
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// EXPORTS //
|
|
39
|
+
|
|
40
|
+
module.exports = main;
|
package/cwd/lib/main.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
* Returns the current working directory of the process.
|
|
30
|
+
*
|
|
31
|
+
* @returns {string} current working directory of the process
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* var dir = cwd();
|
|
35
|
+
* // e.g., returns '/path/to/current/working/directory'
|
|
36
|
+
*/
|
|
37
|
+
function cwd() {
|
|
38
|
+
return proc.cwd();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// EXPORTS //
|
|
43
|
+
|
|
44
|
+
module.exports = cwd;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 returning the current working directory in environments which do not have support for returning the current working directory.
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @returns {string} current working directory
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* var dir = cwd();
|
|
31
|
+
* // returns '/'
|
|
32
|
+
*/
|
|
33
|
+
function cwd() {
|
|
34
|
+
return '/';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// EXPORTS //
|
|
39
|
+
|
|
40
|
+
module.exports = cwd;
|
package/cwd/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/process/cwd",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Return 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
|
+
"bin": {
|
|
17
|
+
"cwd": "./bin/cli"
|
|
18
|
+
},
|
|
19
|
+
"main": "./lib",
|
|
20
|
+
"browser": {
|
|
21
|
+
"./lib": "./lib/polyfill.js",
|
|
22
|
+
"process": "process/"
|
|
23
|
+
},
|
|
24
|
+
"directories": {
|
|
25
|
+
"benchmark": "./benchmark",
|
|
26
|
+
"doc": "./docs",
|
|
27
|
+
"example": "./examples",
|
|
28
|
+
"lib": "./lib",
|
|
29
|
+
"test": "./test"
|
|
30
|
+
},
|
|
31
|
+
"types": "./docs/types",
|
|
32
|
+
"scripts": {},
|
|
33
|
+
"homepage": "https://github.com/stdlib-js/stdlib",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git://github.com/stdlib-js/stdlib.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {},
|
|
42
|
+
"devDependencies": {},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=0.10.0",
|
|
45
|
+
"npm": ">2.7.0"
|
|
46
|
+
},
|
|
47
|
+
"os": [
|
|
48
|
+
"aix",
|
|
49
|
+
"darwin",
|
|
50
|
+
"freebsd",
|
|
51
|
+
"linux",
|
|
52
|
+
"macos",
|
|
53
|
+
"openbsd",
|
|
54
|
+
"sunos",
|
|
55
|
+
"win32",
|
|
56
|
+
"windows",
|
|
57
|
+
"openharmony"
|
|
58
|
+
],
|
|
59
|
+
"keywords": [
|
|
60
|
+
"stdlib",
|
|
61
|
+
"stdutils",
|
|
62
|
+
"stdutil",
|
|
63
|
+
"utilities",
|
|
64
|
+
"utility",
|
|
65
|
+
"utils",
|
|
66
|
+
"util",
|
|
67
|
+
"working",
|
|
68
|
+
"directory",
|
|
69
|
+
"process",
|
|
70
|
+
"dir",
|
|
71
|
+
"cwd",
|
|
72
|
+
"pwd",
|
|
73
|
+
"path"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2021 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
|
+
/* eslint-disable max-lines */
|
|
22
|
+
|
|
23
|
+
import ARGV = require( './../../argv' );
|
|
24
|
+
import chdir = require( './../../chdir' );
|
|
25
|
+
import cwd = require( './../../cwd' );
|
|
26
|
+
import ENV = require( './../../env' );
|
|
27
|
+
import EXEC_PATH = require( './../../exec-path' );
|
|
28
|
+
import getegid = require( './../../getegid' );
|
|
29
|
+
import geteuid = require( './../../geteuid' );
|
|
30
|
+
import getgid = require( './../../getgid' );
|
|
31
|
+
import getuid = require( './../../getuid' );
|
|
32
|
+
import NODE_VERSION = require( './../../node-version' );
|
|
33
|
+
import stdin = require( './../../read-stdin' );
|
|
34
|
+
import umask = require( './../../umask' );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Interface describing the `process` namespace.
|
|
38
|
+
*/
|
|
39
|
+
interface Namespace {
|
|
40
|
+
/**
|
|
41
|
+
* An array containing command-line arguments passed when launching the calling process.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* console.log( ns.ARGV );
|
|
45
|
+
* // => [...]
|
|
46
|
+
*/
|
|
47
|
+
ARGV: typeof ARGV;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Changes the current working directory.
|
|
51
|
+
*
|
|
52
|
+
* ## Notes
|
|
53
|
+
*
|
|
54
|
+
* - 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`.
|
|
55
|
+
*
|
|
56
|
+
* @param path - desired working directory
|
|
57
|
+
* @returns error object or `null`
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* var err = ns.chdir( __dirname );
|
|
61
|
+
* if ( err ) {
|
|
62
|
+
* throw err;
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
chdir: typeof chdir;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the current working directory of the process.
|
|
69
|
+
*
|
|
70
|
+
* @returns current working directory of the process
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* var dir = ns.cwd();
|
|
74
|
+
* // returns '/path/to/current/working/directory'
|
|
75
|
+
*/
|
|
76
|
+
cwd: typeof cwd;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* An object containing the user environment.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* console.dir( ns.ENV );
|
|
83
|
+
*/
|
|
84
|
+
ENV: typeof ENV;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Absolute pathname of the executable which started the current Node.js process.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* if ( ns.EXEC_PATH ) {
|
|
91
|
+
* console.log( 'Executable: %s', ns.EXEC_PATH );
|
|
92
|
+
* } else {
|
|
93
|
+
* console.log( 'Not running in Node.js.' );
|
|
94
|
+
* }
|
|
95
|
+
*/
|
|
96
|
+
EXEC_PATH: typeof EXEC_PATH;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the effective numeric group identity of the calling process.
|
|
100
|
+
*
|
|
101
|
+
* ## Notes
|
|
102
|
+
*
|
|
103
|
+
* - The function only returns an effective group identity on POSIX platforms. For all other platforms (e.g., Windows and Android), the function returns `null`.
|
|
104
|
+
*
|
|
105
|
+
* @returns effective numeric group identity or null
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* var gid = ns.getegid();
|
|
109
|
+
*/
|
|
110
|
+
getegid: typeof getegid;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the effective numeric user identity of the calling process.
|
|
114
|
+
*
|
|
115
|
+
* ## Notes
|
|
116
|
+
*
|
|
117
|
+
* - The function only returns an effective user identity on POSIX platforms. For all other platforms (e.g., Windows and Android), the function returns `null`.
|
|
118
|
+
*
|
|
119
|
+
* @returns effective numeric user identity or null
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* var uid = ns.geteuid();
|
|
123
|
+
*/
|
|
124
|
+
geteuid: typeof geteuid;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns the numeric group identity of the calling process.
|
|
128
|
+
*
|
|
129
|
+
* ## Notes
|
|
130
|
+
*
|
|
131
|
+
* - The function only returns a group identity on POSIX platforms. For all other platforms (e.g., Windows and Android), the function returns `null`.
|
|
132
|
+
*
|
|
133
|
+
* @returns numeric group identity or null
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* var gid = ns.getgid();
|
|
137
|
+
*/
|
|
138
|
+
getgid: typeof getgid;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns the numeric user identity of the calling process.
|
|
142
|
+
*
|
|
143
|
+
* ## Notes
|
|
144
|
+
*
|
|
145
|
+
* - The function only returns a user identity on POSIX platforms. For all other platforms (e.g., Windows and Android), the function returns `null`.
|
|
146
|
+
*
|
|
147
|
+
* @returns numeric user identity or null
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* var uid = ns.getuid();
|
|
151
|
+
*/
|
|
152
|
+
getuid: typeof getuid;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Node version.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* var semver = require( 'semver' );
|
|
159
|
+
*
|
|
160
|
+
* if ( semver.lt( ns.NODE_VERSION, '1.0.0' ) ) {
|
|
161
|
+
* console.log( 'Running on a pre-io.js version...' );
|
|
162
|
+
* }
|
|
163
|
+
* else if ( semver.lt( ns.NODE_VERSION, '4.0.0' ) ) {
|
|
164
|
+
* console.log( 'Running on an io.js version...' );
|
|
165
|
+
* }
|
|
166
|
+
* else {
|
|
167
|
+
* console.log( 'Running on a post-io.js version...' );
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
170
|
+
NODE_VERSION: typeof NODE_VERSION;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Reads data from `stdin`.
|
|
174
|
+
*
|
|
175
|
+
* @param encoding - string encoding. If set, data will be returned as an encoded `string`
|
|
176
|
+
* @param clbk - callback to be invoked upon reading all data from `stdin`
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* function onRead( error, data ) {
|
|
180
|
+
* if ( error ) {
|
|
181
|
+
* throw error;
|
|
182
|
+
* }
|
|
183
|
+
* console.log( data.toString() );
|
|
184
|
+
* // => '...'
|
|
185
|
+
* }
|
|
186
|
+
*
|
|
187
|
+
* ns.stdin( onRead );
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* function onRead( error, data ) {
|
|
191
|
+
* if ( error ) {
|
|
192
|
+
* throw error;
|
|
193
|
+
* }
|
|
194
|
+
* console.log( data );
|
|
195
|
+
* // => '...'
|
|
196
|
+
* }
|
|
197
|
+
*
|
|
198
|
+
* ns.stdin( 'utf8', onRead );
|
|
199
|
+
*/
|
|
200
|
+
stdin: typeof stdin;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Get/set the process mask.
|
|
204
|
+
*
|
|
205
|
+
* @param options - options
|
|
206
|
+
* @param options.symbolic - boolean indicating whether to return a mask using symbolic notation
|
|
207
|
+
* @throws must provide valid options
|
|
208
|
+
* @returns process mask
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* var mask = ns.umask();
|
|
212
|
+
* // returns <number>
|
|
213
|
+
*/
|
|
214
|
+
umask: typeof umask;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Process utilities.
|
|
219
|
+
*/
|
|
220
|
+
declare var ns: Namespace;
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
// EXPORTS //
|
|
224
|
+
|
|
225
|
+
export = ns;
|
package/env/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
# ENV
|
|
22
|
+
|
|
23
|
+
> Object containing the user environment.
|
|
24
|
+
|
|
25
|
+
<section class="usage">
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
var ENV = require( '@stdlib/process/env' );
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### ENV
|
|
34
|
+
|
|
35
|
+
`Object` containing the user environment.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
var user = ENV.USER;
|
|
39
|
+
// returns <string>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
</section>
|
|
43
|
+
|
|
44
|
+
<!-- /.usage -->
|
|
45
|
+
|
|
46
|
+
<section class="notes">
|
|
47
|
+
|
|
48
|
+
## Notes
|
|
49
|
+
|
|
50
|
+
- See [environ(7)][man-environ].
|
|
51
|
+
- Modifications to `ENV` are local to the process in which `ENV` is modified.
|
|
52
|
+
- On Windows systems, environment variables are case insensitive.
|
|
53
|
+
- In browser environments, `ENV` is an **empty** object.
|
|
54
|
+
- Be careful when modifying environment variables as the environment variable object represents shared state. Accordingly, modifications affect all environment variable consumers.
|
|
55
|
+
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
<!-- /.notes -->
|
|
59
|
+
|
|
60
|
+
<section class="examples">
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
<!-- eslint no-undef: "error" -->
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
var ENV = require( '@stdlib/process/env' );
|
|
68
|
+
|
|
69
|
+
console.dir( ENV );
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
</section>
|
|
73
|
+
|
|
74
|
+
<!-- /.examples -->
|
|
75
|
+
|
|
76
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
77
|
+
|
|
78
|
+
<section class="related">
|
|
79
|
+
|
|
80
|
+
* * *
|
|
81
|
+
|
|
82
|
+
## See Also
|
|
83
|
+
|
|
84
|
+
- <span class="package-name">[`@stdlib/process/argv`][@stdlib/process/argv]</span><span class="delimiter">: </span><span class="description">array containing command-line arguments passed when launching the calling process.</span>
|
|
85
|
+
|
|
86
|
+
</section>
|
|
87
|
+
|
|
88
|
+
<!-- /.related -->
|
|
89
|
+
|
|
90
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
91
|
+
|
|
92
|
+
<section class="links">
|
|
93
|
+
|
|
94
|
+
[man-environ]: http://man7.org/linux/man-pages/man7/environ.7.html
|
|
95
|
+
|
|
96
|
+
<!-- <related-links> -->
|
|
97
|
+
|
|
98
|
+
[@stdlib/process/argv]: https://github.com/stdlib-js/process/tree/main/argv
|
|
99
|
+
|
|
100
|
+
<!-- </related-links> -->
|
|
101
|
+
|
|
102
|
+
</section>
|
|
103
|
+
|
|
104
|
+
<!-- /.links -->
|