first commit
This commit is contained in:
30
build/node_modules/executable/cli.js
generated
vendored
Executable file
30
build/node_modules/executable/cli.js
generated
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var meow = require('meow');
|
||||
var executable = require('./');
|
||||
|
||||
var cli = meow({
|
||||
help: [
|
||||
'Usage',
|
||||
' $ executable <file>',
|
||||
'',
|
||||
'Example',
|
||||
' $ executable optipng'
|
||||
].join('\n')
|
||||
});
|
||||
|
||||
if (!cli.input.length) {
|
||||
console.error('Filename required');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
executable(cli.input[0], function (err, exec) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(exec ? 'true' : 'false');
|
||||
process.exit(exec ? 0 : 1);
|
||||
});
|
||||
47
build/node_modules/executable/index.js
generated
vendored
Normal file
47
build/node_modules/executable/index.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
function isExe(mode, gid, uid) {
|
||||
if (process.platform === 'win32') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (mode & parseInt('0001', 8)) ||
|
||||
(mode & parseInt('0010', 8)) && process.getgid && gid === process.getgid() ||
|
||||
(mode & parseInt('0100', 8)) && process.getuid && uid === process.getuid();
|
||||
}
|
||||
|
||||
module.exports = function (name, cb) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Filename required');
|
||||
}
|
||||
|
||||
fs.stat(name, function (err, stats) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stats && stats.isFile() && isExe(stats.mode, stats.gid, stats.uid)) {
|
||||
cb(null, true);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, false);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = function (name) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Filename required');
|
||||
}
|
||||
|
||||
var file = fs.statSync(name);
|
||||
|
||||
if (file && file.isFile() && isExe(file.mode, file.gid, file.uid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
21
build/node_modules/executable/license
generated
vendored
Normal file
21
build/node_modules/executable/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
69
build/node_modules/executable/package.json
generated
vendored
Normal file
69
build/node_modules/executable/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"executable@1.1.0",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "executable@1.1.0",
|
||||
"_id": "executable@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-h3mA6REvM5EGbaNyZd562ENKtNk=",
|
||||
"_location": "/executable",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "executable@1.1.0",
|
||||
"name": "executable",
|
||||
"escapedName": "executable",
|
||||
"rawSpec": "1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/bin-check"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/executable/-/executable-1.1.0.tgz",
|
||||
"_spec": "1.1.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"bin": {
|
||||
"executable": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kevva/executable/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"meow": "^3.1.0"
|
||||
},
|
||||
"description": "Check if a file is executable",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/kevva/executable#readme",
|
||||
"keywords": [
|
||||
"exec"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "executable",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kevva/executable.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
47
build/node_modules/executable/readme.md
generated
vendored
Normal file
47
build/node_modules/executable/readme.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# executable [](https://travis-ci.org/kevva/executable)
|
||||
|
||||
> Check if a file is executable using Node.js
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save executable
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var executable = require('executable');
|
||||
|
||||
executable('bash', function (err, exec) {
|
||||
console.log(exec);
|
||||
//=> true
|
||||
});
|
||||
|
||||
executable.sync('bash');
|
||||
//=> true
|
||||
```
|
||||
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ npm install --global executable
|
||||
```
|
||||
|
||||
```
|
||||
$ executable --help
|
||||
|
||||
Usage
|
||||
$ executable <file>
|
||||
|
||||
Example
|
||||
$ executable optipng
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Mårtensson](https://github.com/kevva)
|
||||
Reference in New Issue
Block a user