Skip to content

Commit 9941828

Browse files
committed
Add operating system CPU arch
1 parent 20bab55 commit 9941828

File tree

11 files changed

+453
-0
lines changed

11 files changed

+453
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Architecture
2+
3+
> Operating system CPU architecture.
4+
5+
<section class="usage">
6+
7+
## Usage
8+
9+
```javascript
10+
var ARCH = require( '@stdlib/os/arch' );
11+
```
12+
13+
#### ARCH
14+
15+
Operating system CPU architecture.
16+
17+
```javascript
18+
console.log( ARCH );
19+
// returns <string>
20+
```
21+
22+
</section>
23+
24+
<!-- /.usage -->
25+
26+
<section class="examples">
27+
28+
## Examples
29+
30+
<!-- eslint no-undef: "error" -->
31+
32+
```javascript
33+
var ARCH = require( '@stdlib/os/arch' );
34+
35+
if ( ARCH === 'arm' || ARCH === 'arm64' ) {
36+
console.log( 'Running on ARM...' );
37+
} else {
38+
console.log( 'Running on something else...' );
39+
}
40+
```
41+
42+
</section>
43+
44+
<!-- /.examples -->
45+
46+
* * *
47+
48+
<section class="cli">
49+
50+
## CLI
51+
52+
<section class="usage">
53+
54+
### Usage
55+
56+
```text
57+
Usage: arch [options]
58+
59+
Options:
60+
61+
-h, --help Print this message.
62+
-V, --version Print the package version.
63+
```
64+
65+
</section>
66+
67+
<!-- /.usage -->
68+
69+
<section class="examples">
70+
71+
### Examples
72+
73+
```bash
74+
$ arch
75+
```
76+
77+
</section>
78+
79+
<!-- /.examples -->
80+
81+
</section>
82+
83+
<!-- /.cli -->
84+
85+
<section class="links">
86+
87+
</section>
88+
89+
<!-- /.links -->
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
// MODULES //
5+
6+
var resolve = require( 'path' ).resolve;
7+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
8+
var CLI = require( '@stdlib/tools/cli' );
9+
var arch = require( './../lib' );
10+
11+
12+
// MAIN //
13+
14+
/**
15+
* Main execution sequence.
16+
*
17+
* @private
18+
*/
19+
function main() {
20+
// Create a command-line interface:
21+
var cli = new CLI({ // eslint-disable-line no-unused-vars
22+
'pkg': require( './../package.json' ),
23+
'options': require( './../etc/cli_opts.json' ),
24+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
25+
'encoding': 'utf8'
26+
})
27+
});
28+
29+
console.log( arch ); // eslint-disable-line no-console
30+
} // end FUNCTION main()
31+
32+
main();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
{{alias}}
3+
Operating system CPU architecture.
4+
5+
Current possible values:
6+
7+
- arm
8+
- arm64
9+
- ia32
10+
- mips
11+
- mipsel
12+
- ppc
13+
- ppc64
14+
- s390
15+
- s390x
16+
- x32
17+
- x64
18+
19+
Examples
20+
--------
21+
> {{alias}}
22+
<string>
23+
24+
See Also
25+
--------
26+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Usage: arch [options]
3+
4+
Options:
5+
6+
-h, --help Print this message.
7+
-V, --version Print the package version.
8+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"boolean": [
3+
"help",
4+
"version"
5+
],
6+
"alias": {
7+
"help": [
8+
"h"
9+
],
10+
"version": [
11+
"V"
12+
]
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
var ARCH = require( './../lib' );
4+
5+
if ( ARCH === 'arm' || ARCH === 'arm64' ) {
6+
console.log( 'Running on ARM...' );
7+
} else {
8+
console.log( 'Running on something else...' );
9+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
/**
4+
* Operating system CPU architecture.
5+
*
6+
* @module @stdlib/os/arch
7+
*
8+
* @example
9+
* var ARCH = require( '@stdlib/os/arch' );
10+
*
11+
* if ( ARCH === 'arm' || ARCH === 'arm64' ) {
12+
* console.log( 'Running on ARM...' );
13+
* } else {
14+
* console.log( 'Running on something else...' );
15+
* }
16+
*/
17+
18+
// MODULES //
19+
20+
var ARCH = require( './main.js' );
21+
22+
23+
// EXPORTS //
24+
25+
module.exports = ARCH;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
// MAIN //
4+
5+
/**
6+
* Operating system CPU architecture.
7+
*
8+
* @constant
9+
* @type {string}
10+
*/
11+
var ARCH = process.arch;
12+
13+
14+
// EXPORTS //
15+
16+
module.exports = ARCH;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"name": "@stdlib/os/arch",
3+
"version": "0.0.0",
4+
"description": "Operating system CPU architecture.",
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+
"arch": "./bin/cli"
18+
},
19+
"main": "./lib",
20+
"directories": {
21+
"bin": "./bin",
22+
"doc": "./docs",
23+
"example": "./examples",
24+
"lib": "./lib",
25+
"test": "./test"
26+
},
27+
"scripts": {},
28+
"homepage": "https://github.com/stdlib-js/stdlib",
29+
"repository": {
30+
"type": "git",
31+
"url": "git://github.com/stdlib-js/stdlib.git"
32+
},
33+
"bugs": {
34+
"url": "https://github.com/stdlib-js/stdlib/issues"
35+
},
36+
"dependencies": {},
37+
"devDependencies": {},
38+
"engines": {
39+
"node": ">=0.10.0",
40+
"npm": ">2.7.0"
41+
},
42+
"os": [
43+
"aix",
44+
"darwin",
45+
"freebsd",
46+
"linux",
47+
"macos",
48+
"openbsd",
49+
"sunos",
50+
"win32",
51+
"windows"
52+
],
53+
"keywords": [
54+
"stdlib",
55+
"stdutils",
56+
"stdutil",
57+
"utils",
58+
"util",
59+
"utilities",
60+
"utility",
61+
"process",
62+
"runtime",
63+
"environment",
64+
"platform",
65+
"os",
66+
"cpu",
67+
"architecture",
68+
"arch"
69+
]
70+
}

0 commit comments

Comments
 (0)