@mrgrain/cdk-esbuild 4.0.0-alpha.7 → 4.0.0-beta.0
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/.jsii +1573 -588
- package/CHANGELOG.md +104 -0
- package/LICENSE +1 -1
- package/README.md +223 -102
- package/lib/asset.d.ts +20 -5
- package/lib/asset.js +31 -19
- package/lib/bundler.d.ts +51 -28
- package/lib/bundler.js +28 -17
- package/lib/code.d.ts +82 -16
- package/lib/code.js +71 -25
- package/lib/esbuild-types.d.ts +49 -18
- package/lib/esbuild-types.js +1 -1
- package/lib/index.d.ts +5 -4
- package/lib/index.js +8 -7
- package/lib/inline-code.d.ts +29 -77
- package/lib/inline-code.js +53 -104
- package/lib/private/dynamic-package.d.ts +41 -0
- package/lib/private/dynamic-package.js +115 -0
- package/lib/private/esbuild-source.d.ts +33 -0
- package/lib/private/esbuild-source.js +59 -0
- package/lib/private/utils.d.ts +7 -0
- package/lib/private/utils.js +23 -0
- package/lib/provider.d.ts +129 -0
- package/lib/provider.js +115 -0
- package/lib/source.d.ts +81 -5
- package/lib/source.js +84 -8
- package/package.json +33 -25
- package/rosetta/default.ts-fixture +32 -0
- package/.gitattributes +0 -24
- package/.projenrc.ts +0 -208
- package/API.md +0 -2477
- package/SECURITY.md +0 -19
- package/lib/esbuild-polyfill.js +0 -2302
- package/lib/esbuild-wrapper.d.ts +0 -3
- package/lib/esbuild-wrapper.js +0 -31
- package/lib/formatMessages.d.ts +0 -18
- package/lib/formatMessages.js +0 -34
- package/node_modules/isexe/.npmignore +0 -2
- package/node_modules/isexe/LICENSE +0 -15
- package/node_modules/isexe/README.md +0 -51
- package/node_modules/isexe/index.js +0 -57
- package/node_modules/isexe/mode.js +0 -41
- package/node_modules/isexe/package.json +0 -35
- package/node_modules/isexe/test/basic.js +0 -221
- package/node_modules/isexe/windows.js +0 -42
- package/node_modules/which/CHANGELOG.md +0 -166
- package/node_modules/which/LICENSE +0 -15
- package/node_modules/which/README.md +0 -54
- package/node_modules/which/bin/node-which +0 -52
- package/node_modules/which/package.json +0 -47
- package/node_modules/which/which.js +0 -125
package/lib/esbuild-wrapper.d.ts
DELETED
package/lib/esbuild-wrapper.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformSync = exports.formatMessagesSync = exports.buildSync = void 0;
|
|
4
|
-
const which = require("which");
|
|
5
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
6
|
-
function esbuild() {
|
|
7
|
-
try {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
9
|
-
return require('esbuild');
|
|
10
|
-
}
|
|
11
|
-
catch (_one) {
|
|
12
|
-
/**
|
|
13
|
-
* esbuild is not installed. We fallback to use a (hopefully available)
|
|
14
|
-
* global binary and our bundled polyfill.
|
|
15
|
-
*/
|
|
16
|
-
try {
|
|
17
|
-
if (!process.env?.ESBUILD_BINARY_PATH) {
|
|
18
|
-
process.env.ESBUILD_BINARY_PATH = which.sync('esbuild');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (_two) {
|
|
22
|
-
throw new Error('The esbuild binary could not be found in path. Please follow the instructions to ensure esbuild is correctly installed.');
|
|
23
|
-
}
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
|
-
return require('./esbuild-polyfill');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.buildSync = esbuild().buildSync;
|
|
29
|
-
exports.formatMessagesSync = esbuild().formatMessagesSync;
|
|
30
|
-
exports.transformSync = esbuild().transformSync;
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNidWlsZC13cmFwcGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2VzYnVpbGQtd3JhcHBlci50cyJdLCJ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
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { WriteStream } from 'tty';
|
|
3
|
-
import { BuildFailure, BuildResult, TransformFailure, TransformResult } from './esbuild-types';
|
|
4
|
-
export declare function printBuildErrors(failure: TransformFailure | BuildFailure, { dest, color, prefix, }?: {
|
|
5
|
-
dest?: WriteStream;
|
|
6
|
-
color?: boolean;
|
|
7
|
-
prefix?: string;
|
|
8
|
-
}): void;
|
|
9
|
-
export declare function printBuildWarnings(failure: TransformFailure | BuildFailure | TransformResult | BuildResult, { dest, color, prefix, }?: {
|
|
10
|
-
dest?: WriteStream;
|
|
11
|
-
color?: boolean;
|
|
12
|
-
prefix?: string;
|
|
13
|
-
}): void;
|
|
14
|
-
export declare function printBuildMessages(failure: TransformFailure | BuildFailure | TransformResult | BuildResult, props?: {
|
|
15
|
-
dest?: WriteStream;
|
|
16
|
-
color?: boolean;
|
|
17
|
-
prefix?: string;
|
|
18
|
-
}): void;
|
package/lib/formatMessages.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printBuildMessages = exports.printBuildWarnings = exports.printBuildErrors = void 0;
|
|
4
|
-
const esbuild_wrapper_1 = require("./esbuild-wrapper");
|
|
5
|
-
function printBuildErrors(failure, { dest = process.stdout, color = true, prefix = '', } = {}) {
|
|
6
|
-
const errors = esbuild_wrapper_1.formatMessagesSync(failure.errors, {
|
|
7
|
-
kind: 'error',
|
|
8
|
-
color,
|
|
9
|
-
});
|
|
10
|
-
if (errors.length > 0) {
|
|
11
|
-
dest.write(`${prefix}Errors:\n\n`);
|
|
12
|
-
dest.write(errors.join('\n\n'));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.printBuildErrors = printBuildErrors;
|
|
16
|
-
function printBuildWarnings(failure, { dest = process.stdout, color = true, prefix = '', } = {}) {
|
|
17
|
-
const warnings = esbuild_wrapper_1.formatMessagesSync(failure.warnings, {
|
|
18
|
-
kind: 'warning',
|
|
19
|
-
color,
|
|
20
|
-
});
|
|
21
|
-
if (warnings.length > 0) {
|
|
22
|
-
dest.write(`${prefix}Warning:\n\n`);
|
|
23
|
-
dest.write(warnings.join('\n\n'));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.printBuildWarnings = printBuildWarnings;
|
|
27
|
-
function printBuildMessages(failure, props = {}) {
|
|
28
|
-
printBuildWarnings(failure, props);
|
|
29
|
-
if (failure.errors) {
|
|
30
|
-
printBuildErrors(failure, props);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.printBuildMessages = printBuildMessages;
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybWF0TWVzc2FnZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZm9ybWF0TWVzc2FnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBUUEsdURBQXVEO0FBRXZELFNBQWdCLGdCQUFnQixDQUM5QixPQUF3QyxFQUN4QyxFQUNFLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxFQUNyQixLQUFLLEdBQUcsSUFBSSxFQUNaLE1BQU0sR0FBRyxFQUFFLE1BS1QsRUFBRTtJQUVOLE1BQU0sTUFBTSxHQUFHLG9DQUFrQixDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUU7UUFDaEQsSUFBSSxFQUFFLE9BQU87UUFDYixLQUFLO0tBQ04sQ0FBQyxDQUFDO0lBRUgsSUFBSSxNQUFNLENBQUMsTUFBTSxHQUFHLENBQUMsRUFBRTtRQUNyQixJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsTUFBTSxhQUFhLENBQUMsQ0FBQztRQUNuQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsTU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ZXN0PzogV3JpdGVTdHJlYW07XG4gICAgY29sb3I/OiBib29sZWFuO1xuICAgIHByZWZpeD86IHN0cmluZztcbiAgfSA9IHt9LFxuKTogdm9pZCB7XG4gIGNvbnN0IHdhcm5pbmdzID0gZm9ybWF0TWVzc2FnZXNTeW5jKGZhaWx1cmUud2FybmluZ3MsIHtcbiAgICBraW5kOiAnd2FybmluZycsXG4gICAgY29sb3IsXG4gIH0pO1xuXG4gIGlmICh3YXJuaW5ncy5sZW5ndGggPiAwKSB7XG4gICAgZGVzdC53cml0ZShgJHtwcmVmaXh9V2FybmluZzpcXG5cXG5gKTtcbiAgICBkZXN0LndyaXRlKHdhcm5pbmdzLmpvaW4oJ1xcblxcbicpKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gcHJpbnRCdWlsZE1lc3NhZ2VzKFxuICBmYWlsdXJlOiBUcmFuc2Zvcm1GYWlsdXJlIHwgQnVpbGRGYWlsdXJlIHwgVHJhbnNmb3JtUmVzdWx0IHwgQnVpbGRSZXN1bHQsXG4gIHByb3BzOiB7XG4gICAgZGVzdD86IFdyaXRlU3RyZWFtO1xuICAgIGNvbG9yPzogYm9vbGVhbjtcbiAgICBwcmVmaXg/OiBzdHJpbmc7XG4gIH0gPSB7fSxcbik6IHZvaWQge1xuICBwcmludEJ1aWxkV2FybmluZ3MoZmFpbHVyZSwgcHJvcHMpO1xuXG4gIGlmICgoZmFpbHVyZSBhcyBCdWlsZEZhaWx1cmUpLmVycm9ycykge1xuICAgIHByaW50QnVpbGRFcnJvcnMoZmFpbHVyZSBhcyBCdWlsZEZhaWx1cmUsIHByb3BzKTtcbiAgfVxufVxuIl19
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
The ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
-
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# isexe
|
|
2
|
-
|
|
3
|
-
Minimal module to check if a file is executable, and a normal file.
|
|
4
|
-
|
|
5
|
-
Uses `fs.stat` and tests against the `PATHEXT` environment variable on
|
|
6
|
-
Windows.
|
|
7
|
-
|
|
8
|
-
## USAGE
|
|
9
|
-
|
|
10
|
-
```javascript
|
|
11
|
-
var isexe = require('isexe')
|
|
12
|
-
isexe('some-file-name', function (err, isExe) {
|
|
13
|
-
if (err) {
|
|
14
|
-
console.error('probably file does not exist or something', err)
|
|
15
|
-
} else if (isExe) {
|
|
16
|
-
console.error('this thing can be run')
|
|
17
|
-
} else {
|
|
18
|
-
console.error('cannot be run')
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
// same thing but synchronous, throws errors
|
|
23
|
-
var isExe = isexe.sync('some-file-name')
|
|
24
|
-
|
|
25
|
-
// treat errors as just "not executable"
|
|
26
|
-
isexe('maybe-missing-file', { ignoreErrors: true }, callback)
|
|
27
|
-
var isExe = isexe.sync('maybe-missing-file', { ignoreErrors: true })
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## API
|
|
31
|
-
|
|
32
|
-
### `isexe(path, [options], [callback])`
|
|
33
|
-
|
|
34
|
-
Check if the path is executable. If no callback provided, and a
|
|
35
|
-
global `Promise` object is available, then a Promise will be returned.
|
|
36
|
-
|
|
37
|
-
Will raise whatever errors may be raised by `fs.stat`, unless
|
|
38
|
-
`options.ignoreErrors` is set to true.
|
|
39
|
-
|
|
40
|
-
### `isexe.sync(path, [options])`
|
|
41
|
-
|
|
42
|
-
Same as `isexe` but returns the value and throws any errors raised.
|
|
43
|
-
|
|
44
|
-
### Options
|
|
45
|
-
|
|
46
|
-
* `ignoreErrors` Treat all errors as "no, this is not executable", but
|
|
47
|
-
don't raise them.
|
|
48
|
-
* `uid` Number to use as the user id
|
|
49
|
-
* `gid` Number to use as the group id
|
|
50
|
-
* `pathExt` List of path extensions to use instead of `PATHEXT`
|
|
51
|
-
environment variable on Windows.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var fs = require('fs')
|
|
2
|
-
var core
|
|
3
|
-
if (process.platform === 'win32' || global.TESTING_WINDOWS) {
|
|
4
|
-
core = require('./windows.js')
|
|
5
|
-
} else {
|
|
6
|
-
core = require('./mode.js')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = isexe
|
|
10
|
-
isexe.sync = sync
|
|
11
|
-
|
|
12
|
-
function isexe (path, options, cb) {
|
|
13
|
-
if (typeof options === 'function') {
|
|
14
|
-
cb = options
|
|
15
|
-
options = {}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!cb) {
|
|
19
|
-
if (typeof Promise !== 'function') {
|
|
20
|
-
throw new TypeError('callback not provided')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return new Promise(function (resolve, reject) {
|
|
24
|
-
isexe(path, options || {}, function (er, is) {
|
|
25
|
-
if (er) {
|
|
26
|
-
reject(er)
|
|
27
|
-
} else {
|
|
28
|
-
resolve(is)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
core(path, options || {}, function (er, is) {
|
|
35
|
-
// ignore EACCES because that just means we aren't allowed to run it
|
|
36
|
-
if (er) {
|
|
37
|
-
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|
38
|
-
er = null
|
|
39
|
-
is = false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
cb(er, is)
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function sync (path, options) {
|
|
47
|
-
// my kingdom for a filtered catch
|
|
48
|
-
try {
|
|
49
|
-
return core.sync(path, options || {})
|
|
50
|
-
} catch (er) {
|
|
51
|
-
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|
52
|
-
return false
|
|
53
|
-
} else {
|
|
54
|
-
throw er
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module.exports = isexe
|
|
2
|
-
isexe.sync = sync
|
|
3
|
-
|
|
4
|
-
var fs = require('fs')
|
|
5
|
-
|
|
6
|
-
function isexe (path, options, cb) {
|
|
7
|
-
fs.stat(path, function (er, stat) {
|
|
8
|
-
cb(er, er ? false : checkStat(stat, options))
|
|
9
|
-
})
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function sync (path, options) {
|
|
13
|
-
return checkStat(fs.statSync(path), options)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function checkStat (stat, options) {
|
|
17
|
-
return stat.isFile() && checkMode(stat, options)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function checkMode (stat, options) {
|
|
21
|
-
var mod = stat.mode
|
|
22
|
-
var uid = stat.uid
|
|
23
|
-
var gid = stat.gid
|
|
24
|
-
|
|
25
|
-
var myUid = options.uid !== undefined ?
|
|
26
|
-
options.uid : process.getuid && process.getuid()
|
|
27
|
-
var myGid = options.gid !== undefined ?
|
|
28
|
-
options.gid : process.getgid && process.getgid()
|
|
29
|
-
|
|
30
|
-
var u = parseInt('100', 8)
|
|
31
|
-
var g = parseInt('010', 8)
|
|
32
|
-
var o = parseInt('001', 8)
|
|
33
|
-
var ug = u | g
|
|
34
|
-
|
|
35
|
-
var ret = (mod & o) ||
|
|
36
|
-
(mod & g) && gid === myGid ||
|
|
37
|
-
(mod & u) && uid === myUid ||
|
|
38
|
-
(mod & ug) && myUid === 0
|
|
39
|
-
|
|
40
|
-
return ret
|
|
41
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "isexe",
|
|
3
|
-
"version": "2.0.0",
|
|
4
|
-
"description": "Minimal module to check if a file is executable.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"directories": {
|
|
7
|
-
"test": "test"
|
|
8
|
-
},
|
|
9
|
-
"devDependencies": {
|
|
10
|
-
"mkdirp": "^0.5.1",
|
|
11
|
-
"rimraf": "^2.5.0",
|
|
12
|
-
"tap": "^10.3.0"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"test": "tap test/*.js --100",
|
|
16
|
-
"preversion": "npm test",
|
|
17
|
-
"postversion": "npm publish",
|
|
18
|
-
"postpublish": "git push origin --all; git push origin --tags"
|
|
19
|
-
},
|
|
20
|
-
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/isaacs/isexe.git"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [],
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/isaacs/isexe/issues"
|
|
29
|
-
},
|
|
30
|
-
"homepage": "https://github.com/isaacs/isexe#readme"
|
|
31
|
-
|
|
32
|
-
,"_resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
|
|
33
|
-
,"_integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
|
|
34
|
-
,"_from": "isexe@2.0.0"
|
|
35
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
var t = require('tap')
|
|
2
|
-
var fs = require('fs')
|
|
3
|
-
var path = require('path')
|
|
4
|
-
var fixture = path.resolve(__dirname, 'fixtures')
|
|
5
|
-
var meow = fixture + '/meow.cat'
|
|
6
|
-
var mine = fixture + '/mine.cat'
|
|
7
|
-
var ours = fixture + '/ours.cat'
|
|
8
|
-
var fail = fixture + '/fail.false'
|
|
9
|
-
var noent = fixture + '/enoent.exe'
|
|
10
|
-
var mkdirp = require('mkdirp')
|
|
11
|
-
var rimraf = require('rimraf')
|
|
12
|
-
|
|
13
|
-
var isWindows = process.platform === 'win32'
|
|
14
|
-
var hasAccess = typeof fs.access === 'function'
|
|
15
|
-
var winSkip = isWindows && 'windows'
|
|
16
|
-
var accessSkip = !hasAccess && 'no fs.access function'
|
|
17
|
-
var hasPromise = typeof Promise === 'function'
|
|
18
|
-
var promiseSkip = !hasPromise && 'no global Promise'
|
|
19
|
-
|
|
20
|
-
function reset () {
|
|
21
|
-
delete require.cache[require.resolve('../')]
|
|
22
|
-
return require('../')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
t.test('setup fixtures', function (t) {
|
|
26
|
-
rimraf.sync(fixture)
|
|
27
|
-
mkdirp.sync(fixture)
|
|
28
|
-
fs.writeFileSync(meow, '#!/usr/bin/env cat\nmeow\n')
|
|
29
|
-
fs.chmodSync(meow, parseInt('0755', 8))
|
|
30
|
-
fs.writeFileSync(fail, '#!/usr/bin/env false\n')
|
|
31
|
-
fs.chmodSync(fail, parseInt('0644', 8))
|
|
32
|
-
fs.writeFileSync(mine, '#!/usr/bin/env cat\nmine\n')
|
|
33
|
-
fs.chmodSync(mine, parseInt('0744', 8))
|
|
34
|
-
fs.writeFileSync(ours, '#!/usr/bin/env cat\nours\n')
|
|
35
|
-
fs.chmodSync(ours, parseInt('0754', 8))
|
|
36
|
-
t.end()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
t.test('promise', { skip: promiseSkip }, function (t) {
|
|
40
|
-
var isexe = reset()
|
|
41
|
-
t.test('meow async', function (t) {
|
|
42
|
-
isexe(meow).then(function (is) {
|
|
43
|
-
t.ok(is)
|
|
44
|
-
t.end()
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
t.test('fail async', function (t) {
|
|
48
|
-
isexe(fail).then(function (is) {
|
|
49
|
-
t.notOk(is)
|
|
50
|
-
t.end()
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
t.test('noent async', function (t) {
|
|
54
|
-
isexe(noent).catch(function (er) {
|
|
55
|
-
t.ok(er)
|
|
56
|
-
t.end()
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
t.test('noent ignore async', function (t) {
|
|
60
|
-
isexe(noent, { ignoreErrors: true }).then(function (is) {
|
|
61
|
-
t.notOk(is)
|
|
62
|
-
t.end()
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
t.end()
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
t.test('no promise', function (t) {
|
|
69
|
-
global.Promise = null
|
|
70
|
-
var isexe = reset()
|
|
71
|
-
t.throws('try to meow a promise', function () {
|
|
72
|
-
isexe(meow)
|
|
73
|
-
})
|
|
74
|
-
t.end()
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
t.test('access', { skip: accessSkip || winSkip }, function (t) {
|
|
78
|
-
runTest(t)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
t.test('mode', { skip: winSkip }, function (t) {
|
|
82
|
-
delete fs.access
|
|
83
|
-
delete fs.accessSync
|
|
84
|
-
var isexe = reset()
|
|
85
|
-
t.ok(isexe.sync(ours, { uid: 0, gid: 0 }))
|
|
86
|
-
t.ok(isexe.sync(mine, { uid: 0, gid: 0 }))
|
|
87
|
-
runTest(t)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
t.test('windows', function (t) {
|
|
91
|
-
global.TESTING_WINDOWS = true
|
|
92
|
-
var pathExt = '.EXE;.CAT;.CMD;.COM'
|
|
93
|
-
t.test('pathExt option', function (t) {
|
|
94
|
-
runTest(t, { pathExt: '.EXE;.CAT;.CMD;.COM' })
|
|
95
|
-
})
|
|
96
|
-
t.test('pathExt env', function (t) {
|
|
97
|
-
process.env.PATHEXT = pathExt
|
|
98
|
-
runTest(t)
|
|
99
|
-
})
|
|
100
|
-
t.test('no pathExt', function (t) {
|
|
101
|
-
// with a pathExt of '', any filename is fine.
|
|
102
|
-
// so the "fail" one would still pass.
|
|
103
|
-
runTest(t, { pathExt: '', skipFail: true })
|
|
104
|
-
})
|
|
105
|
-
t.test('pathext with empty entry', function (t) {
|
|
106
|
-
// with a pathExt of '', any filename is fine.
|
|
107
|
-
// so the "fail" one would still pass.
|
|
108
|
-
runTest(t, { pathExt: ';' + pathExt, skipFail: true })
|
|
109
|
-
})
|
|
110
|
-
t.end()
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
t.test('cleanup', function (t) {
|
|
114
|
-
rimraf.sync(fixture)
|
|
115
|
-
t.end()
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
function runTest (t, options) {
|
|
119
|
-
var isexe = reset()
|
|
120
|
-
|
|
121
|
-
var optionsIgnore = Object.create(options || {})
|
|
122
|
-
optionsIgnore.ignoreErrors = true
|
|
123
|
-
|
|
124
|
-
if (!options || !options.skipFail) {
|
|
125
|
-
t.notOk(isexe.sync(fail, options))
|
|
126
|
-
}
|
|
127
|
-
t.notOk(isexe.sync(noent, optionsIgnore))
|
|
128
|
-
if (!options) {
|
|
129
|
-
t.ok(isexe.sync(meow))
|
|
130
|
-
} else {
|
|
131
|
-
t.ok(isexe.sync(meow, options))
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
t.ok(isexe.sync(mine, options))
|
|
135
|
-
t.ok(isexe.sync(ours, options))
|
|
136
|
-
t.throws(function () {
|
|
137
|
-
isexe.sync(noent, options)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
t.test('meow async', function (t) {
|
|
141
|
-
if (!options) {
|
|
142
|
-
isexe(meow, function (er, is) {
|
|
143
|
-
if (er) {
|
|
144
|
-
throw er
|
|
145
|
-
}
|
|
146
|
-
t.ok(is)
|
|
147
|
-
t.end()
|
|
148
|
-
})
|
|
149
|
-
} else {
|
|
150
|
-
isexe(meow, options, function (er, is) {
|
|
151
|
-
if (er) {
|
|
152
|
-
throw er
|
|
153
|
-
}
|
|
154
|
-
t.ok(is)
|
|
155
|
-
t.end()
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
t.test('mine async', function (t) {
|
|
161
|
-
isexe(mine, options, function (er, is) {
|
|
162
|
-
if (er) {
|
|
163
|
-
throw er
|
|
164
|
-
}
|
|
165
|
-
t.ok(is)
|
|
166
|
-
t.end()
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
t.test('ours async', function (t) {
|
|
171
|
-
isexe(ours, options, function (er, is) {
|
|
172
|
-
if (er) {
|
|
173
|
-
throw er
|
|
174
|
-
}
|
|
175
|
-
t.ok(is)
|
|
176
|
-
t.end()
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
if (!options || !options.skipFail) {
|
|
181
|
-
t.test('fail async', function (t) {
|
|
182
|
-
isexe(fail, options, function (er, is) {
|
|
183
|
-
if (er) {
|
|
184
|
-
throw er
|
|
185
|
-
}
|
|
186
|
-
t.notOk(is)
|
|
187
|
-
t.end()
|
|
188
|
-
})
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
t.test('noent async', function (t) {
|
|
193
|
-
isexe(noent, options, function (er, is) {
|
|
194
|
-
t.ok(er)
|
|
195
|
-
t.notOk(is)
|
|
196
|
-
t.end()
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
t.test('noent ignore async', function (t) {
|
|
201
|
-
isexe(noent, optionsIgnore, function (er, is) {
|
|
202
|
-
if (er) {
|
|
203
|
-
throw er
|
|
204
|
-
}
|
|
205
|
-
t.notOk(is)
|
|
206
|
-
t.end()
|
|
207
|
-
})
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
t.test('directory is not executable', function (t) {
|
|
211
|
-
isexe(__dirname, options, function (er, is) {
|
|
212
|
-
if (er) {
|
|
213
|
-
throw er
|
|
214
|
-
}
|
|
215
|
-
t.notOk(is)
|
|
216
|
-
t.end()
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
t.end()
|
|
221
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module.exports = isexe
|
|
2
|
-
isexe.sync = sync
|
|
3
|
-
|
|
4
|
-
var fs = require('fs')
|
|
5
|
-
|
|
6
|
-
function checkPathExt (path, options) {
|
|
7
|
-
var pathext = options.pathExt !== undefined ?
|
|
8
|
-
options.pathExt : process.env.PATHEXT
|
|
9
|
-
|
|
10
|
-
if (!pathext) {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
pathext = pathext.split(';')
|
|
15
|
-
if (pathext.indexOf('') !== -1) {
|
|
16
|
-
return true
|
|
17
|
-
}
|
|
18
|
-
for (var i = 0; i < pathext.length; i++) {
|
|
19
|
-
var p = pathext[i].toLowerCase()
|
|
20
|
-
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
21
|
-
return true
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return false
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function checkStat (stat, path, options) {
|
|
28
|
-
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
return checkPathExt(path, options)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function isexe (path, options, cb) {
|
|
35
|
-
fs.stat(path, function (er, stat) {
|
|
36
|
-
cb(er, er ? false : checkStat(stat, path, options))
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function sync (path, options) {
|
|
41
|
-
return checkStat(fs.statSync(path), path, options)
|
|
42
|
-
}
|