hooch 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/hooch.js +395 -1
  3. data/jasmine/jasmine-fixture.js +433 -0
  4. data/jasmine/node_modules/karma-chrome-launcher/CHANGELOG.md +108 -0
  5. data/jasmine/node_modules/karma-chrome-launcher/LICENSE +20 -0
  6. data/jasmine/node_modules/karma-chrome-launcher/README.md +49 -0
  7. data/jasmine/node_modules/karma-chrome-launcher/examples/simple/index.spec.js +5 -0
  8. data/jasmine/node_modules/karma-chrome-launcher/examples/simple/karma.conf.js +32 -0
  9. data/jasmine/node_modules/karma-chrome-launcher/gruntfile.js +63 -0
  10. data/jasmine/node_modules/karma-chrome-launcher/index.js +181 -0
  11. data/jasmine/node_modules/karma-chrome-launcher/node_modules/.bin/which +14 -0
  12. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/index.js +41 -0
  13. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/license +21 -0
  14. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/node_modules/null-check/index.js +19 -0
  15. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/node_modules/null-check/license +21 -0
  16. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/node_modules/null-check/package.json +65 -0
  17. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/node_modules/null-check/readme.md +34 -0
  18. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/package.json +71 -0
  19. data/jasmine/node_modules/karma-chrome-launcher/node_modules/fs-access/readme.md +53 -0
  20. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/.travis.yml +8 -0
  21. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/LICENSE +15 -0
  22. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/README.md +34 -0
  23. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/bin/which +14 -0
  24. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/LICENSE +21 -0
  25. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/README.md +53 -0
  26. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/index.js +27 -0
  27. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/node_modules/is-relative/LICENSE-MIT +21 -0
  28. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/node_modules/is-relative/README.md +38 -0
  29. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/node_modules/is-relative/index.js +21 -0
  30. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/node_modules/is-relative/package.json +75 -0
  31. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/node_modules/is-absolute/package.json +75 -0
  32. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/package.json +56 -0
  33. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/test/basic.js +99 -0
  34. data/jasmine/node_modules/karma-chrome-launcher/node_modules/which/which.js +111 -0
  35. data/jasmine/node_modules/karma-chrome-launcher/package.json +142 -0
  36. data/jasmine/node_modules/karma-chrome-launcher/test/jsflags.spec.js +53 -0
  37. data/jasmine/spec/hoochSpec.js +66 -0
  38. data/lib/hooch/version.rb +1 -1
  39. metadata +37 -3
@@ -0,0 +1,63 @@
1
+ module.exports = function (grunt) {
2
+ grunt.initConfig({
3
+ pkgFile: 'package.json',
4
+ simplemocha: {
5
+ options: {
6
+ ui: 'bdd',
7
+ reporter: 'dot'
8
+ },
9
+ unit: {
10
+ src: [
11
+ 'test/mocha-globals.js',
12
+ 'test/*.spec.js'
13
+ ]
14
+ }
15
+ },
16
+ 'npm-contributors': {
17
+ options: {
18
+ commitMessage: 'chore: update contributors'
19
+ }
20
+ },
21
+ bump: {
22
+ options: {
23
+ commitMessage: 'chore: release v%VERSION%',
24
+ pushTo: 'upstream',
25
+ commitFiles: [
26
+ 'package.json',
27
+ 'CHANGELOG.md'
28
+ ]
29
+ }
30
+ },
31
+ karma: {
32
+ options: {
33
+ singleRun: true
34
+ },
35
+ simple: {
36
+ configFile: 'examples/simple/karma.conf.js'
37
+ }
38
+ },
39
+ eslint: {
40
+ target: [
41
+ 'index.js',
42
+ 'gruntfile.js',
43
+ 'test/*.js',
44
+ 'examples/**/*.js'
45
+ ]
46
+ }
47
+ })
48
+
49
+ require('load-grunt-tasks')(grunt)
50
+
51
+ grunt.registerTask('test', ['simplemocha'])
52
+ grunt.registerTask('default', ['eslint', 'test'])
53
+
54
+ grunt.registerTask('release', 'Bump the version and publish to NPM.', function (type) {
55
+ grunt.task.run([
56
+ 'npm-contributors',
57
+ 'bump-only:' + (type || 'patch'),
58
+ 'changelog',
59
+ 'bump-commit',
60
+ 'npm-publish'
61
+ ])
62
+ })
63
+ }
@@ -0,0 +1,181 @@
1
+ var fsAccess = require('fs-access')
2
+ var path = require('path')
3
+ var which = require('which')
4
+
5
+ function isJSFlags (flag) {
6
+ return flag.indexOf('--js-flags=') === 0
7
+ }
8
+
9
+ function sanitizeJSFlags (flag) {
10
+ var test = /--js-flags=(['"])/.exec(flag)
11
+ if (!test) {
12
+ return flag
13
+ }
14
+ var escapeChar = test[1]
15
+ var endExp = new RegExp(escapeChar + '$')
16
+ var startExp = new RegExp('--js-flags=' + escapeChar)
17
+ return flag.replace(startExp, '--js-flags=').replace(endExp, '')
18
+ }
19
+
20
+ var ChromeBrowser = function (baseBrowserDecorator, args) {
21
+ baseBrowserDecorator(this)
22
+
23
+ var flags = args.flags || []
24
+
25
+ this._getOptions = function (url) {
26
+ // Chrome CLI options
27
+ // http://peter.sh/experiments/chromium-command-line-switches/
28
+ flags.forEach(function (flag, i) {
29
+ if (isJSFlags(flag)) {
30
+ flags[i] = sanitizeJSFlags(flag)
31
+ }
32
+ })
33
+
34
+ return [
35
+ '--user-data-dir=' + this._tempDir,
36
+ '--no-default-browser-check',
37
+ '--no-first-run',
38
+ '--disable-default-apps',
39
+ '--disable-popup-blocking',
40
+ '--disable-translate'
41
+ ].concat(flags, [url])
42
+ }
43
+ }
44
+
45
+ // Return location of chrome.exe file for a given Chrome directory (available: "Chrome", "Chrome SxS").
46
+ function getChromeExe (chromeDirName) {
47
+ // Only run these checks on win32
48
+ if (process.platform !== 'win32') {
49
+ return null
50
+ }
51
+ var windowsChromeDirectory, i, prefix
52
+ var suffix = '\\Google\\' + chromeDirName + '\\Application\\chrome.exe'
53
+ var prefixes = [process.env.LOCALAPPDATA, process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']]
54
+
55
+ for (i = 0; i < prefixes.length; i++) {
56
+ prefix = prefixes[i]
57
+ try {
58
+ windowsChromeDirectory = path.join(prefix, suffix)
59
+ fsAccess.sync(windowsChromeDirectory)
60
+ return windowsChromeDirectory
61
+ } catch (e) {}
62
+ }
63
+
64
+ return windowsChromeDirectory
65
+ }
66
+
67
+ function getBin (commands) {
68
+ // Don't run these checks on win32
69
+ if (process.platform !== 'linux') {
70
+ return null
71
+ }
72
+ var bin, i
73
+ for (i = 0; i < commands.length; i++) {
74
+ try {
75
+ if (which.sync(commands[i])) {
76
+ bin = commands[i]
77
+ break
78
+ }
79
+ } catch (e) {}
80
+ }
81
+ return bin
82
+ }
83
+
84
+ function getChromeDarwin (defaultPath) {
85
+ if (process.platform !== 'darwin') {
86
+ return null
87
+ }
88
+
89
+ try {
90
+ var homePath = path.join(process.env.HOME, defaultPath)
91
+ fsAccess.sync(homePath)
92
+ return homePath
93
+ } catch (e) {
94
+ return defaultPath
95
+ }
96
+ }
97
+
98
+ ChromeBrowser.prototype = {
99
+ name: 'Chrome',
100
+
101
+ DEFAULT_CMD: {
102
+ // Try chromium-browser before chromium to avoid conflict with the legacy
103
+ // chromium-bsu package previously known as 'chromium' in Debian and Ubuntu.
104
+ linux: getBin(['chromium-browser', 'chromium', 'google-chrome', 'google-chrome-stable']),
105
+ darwin: getChromeDarwin('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'),
106
+ win32: getChromeExe('Chrome')
107
+ },
108
+ ENV_CMD: 'CHROME_BIN'
109
+ }
110
+
111
+ ChromeBrowser.$inject = ['baseBrowserDecorator', 'args']
112
+
113
+ function canaryGetOptions (url, args, parent) {
114
+ // disable crankshaft optimizations, as it causes lot of memory leaks (as of Chrome 23.0)
115
+ var flags = args.flags || []
116
+ var augmentedFlags
117
+ var customFlags = '--nocrankshaft --noopt'
118
+
119
+ flags.forEach(function (flag) {
120
+ if (isJSFlags(flag)) {
121
+ augmentedFlags = sanitizeJSFlags(flag) + ' ' + customFlags
122
+ }
123
+ })
124
+
125
+ return parent.call(this, url).concat([augmentedFlags || '--js-flags=' + customFlags])
126
+ }
127
+
128
+ var ChromeCanaryBrowser = function (baseBrowserDecorator, args) {
129
+ ChromeBrowser.apply(this, arguments)
130
+
131
+ var parentOptions = this._getOptions
132
+ this._getOptions = function (url) {
133
+ return canaryGetOptions.call(this, url, args, parentOptions)
134
+ }
135
+ }
136
+
137
+ ChromeCanaryBrowser.prototype = {
138
+ name: 'ChromeCanary',
139
+
140
+ DEFAULT_CMD: {
141
+ linux: 'google-chrome-canary',
142
+ darwin: getChromeDarwin('/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'),
143
+ win32: getChromeExe('Chrome SxS')
144
+ },
145
+ ENV_CMD: 'CHROME_CANARY_BIN'
146
+ }
147
+
148
+ ChromeCanaryBrowser.$inject = ['baseBrowserDecorator', 'args']
149
+
150
+ var DartiumBrowser = function () {
151
+ ChromeBrowser.apply(this, arguments)
152
+
153
+ var checkedFlag = '--checked'
154
+ var dartFlags = process.env.DART_FLAGS || ''
155
+ var flags = dartFlags.split(' ')
156
+ if (flags.indexOf(checkedFlag) === -1) {
157
+ flags.push(checkedFlag)
158
+ process.env.DART_FLAGS = flags.join(' ')
159
+ }
160
+ }
161
+
162
+ DartiumBrowser.prototype = {
163
+ name: 'Dartium',
164
+ DEFAULT_CMD: {},
165
+ ENV_CMD: 'DARTIUM_BIN'
166
+ }
167
+
168
+ DartiumBrowser.$inject = ['baseBrowserDecorator', 'args']
169
+
170
+ // PUBLISH DI MODULE
171
+ module.exports = {
172
+ 'launcher:Chrome': ['type', ChromeBrowser],
173
+ 'launcher:ChromeCanary': ['type', ChromeCanaryBrowser],
174
+ 'launcher:Dartium': ['type', DartiumBrowser]
175
+ }
176
+
177
+ module.exports.test = {
178
+ isJSFlags: isJSFlags,
179
+ sanitizeJSFlags: sanitizeJSFlags,
180
+ canaryGetOptions: canaryGetOptions
181
+ }
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ var which = require("../")
3
+ if (process.argv.length < 3) {
4
+ console.error("Usage: which <thing>")
5
+ process.exit(1)
6
+ }
7
+
8
+ which(process.argv[2], function (er, thing) {
9
+ if (er) {
10
+ console.error(er.message)
11
+ process.exit(er.errno || 127)
12
+ }
13
+ console.log(thing)
14
+ })
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+ var fs = require('fs');
3
+ var nullCheck = require('null-check');
4
+
5
+ var access = module.exports = function (pth, mode, cb) {
6
+ if (typeof pth !== 'string') {
7
+ throw new TypeError('path must be a string');
8
+ }
9
+
10
+ if (typeof mode === 'function') {
11
+ cb = mode;
12
+ mode = access.F_OK;
13
+ } else if (typeof cb !== 'function') {
14
+ throw new TypeError('callback must be a function');
15
+ }
16
+
17
+ if (!nullCheck(pth, cb)) {
18
+ return;
19
+ }
20
+
21
+ mode = mode | 0;
22
+
23
+ if (mode === access.F_OK) {
24
+ fs.stat(pth, cb);
25
+ }
26
+ };
27
+
28
+ access.sync = function (pth, mode) {
29
+ nullCheck(pth);
30
+
31
+ mode = mode === undefined ? access.F_OK : mode | 0;
32
+
33
+ if (mode === access.F_OK) {
34
+ fs.statSync(pth);
35
+ }
36
+ };
37
+
38
+ access.F_OK = 0;
39
+ access.R_OK = 4;
40
+ access.W_OK = 2;
41
+ access.X_OK = 1;
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+ module.exports = function (pth, cb) {
3
+ if (String(pth).indexOf('\u0000') !== -1) {
4
+ var err = new Error('Path must be a string without null bytes.');
5
+ err.code = 'ENOENT';
6
+
7
+ if (typeof cb !== 'function') {
8
+ throw err;
9
+ }
10
+
11
+ process.nextTick(function () {
12
+ cb(err);
13
+ });
14
+
15
+ return false;
16
+ }
17
+
18
+ return true;
19
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "null-check",
3
+ "version": "1.0.0",
4
+ "description": "Ensure a path doesn't contain null bytes",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/sindresorhus/null-check"
9
+ },
10
+ "author": {
11
+ "name": "Sindre Sorhus",
12
+ "email": "sindresorhus@gmail.com",
13
+ "url": "sindresorhus.com"
14
+ },
15
+ "engines": {
16
+ "node": ">=0.10.0"
17
+ },
18
+ "scripts": {
19
+ "test": "node test.js"
20
+ },
21
+ "files": [
22
+ "index.js"
23
+ ],
24
+ "keywords": [
25
+ "built-in",
26
+ "core",
27
+ "ponyfill",
28
+ "polyfill",
29
+ "shim",
30
+ "fs",
31
+ "path",
32
+ "null",
33
+ "bytes",
34
+ "check"
35
+ ],
36
+ "devDependencies": {
37
+ "ava": "0.0.4"
38
+ },
39
+ "gitHead": "bcdcbc68e4735aa5222a2c5575335041cd59ebaa",
40
+ "bugs": {
41
+ "url": "https://github.com/sindresorhus/null-check/issues"
42
+ },
43
+ "homepage": "https://github.com/sindresorhus/null-check",
44
+ "_id": "null-check@1.0.0",
45
+ "_shasum": "977dffd7176012b9ec30d2a39db5cf72a0439edd",
46
+ "_from": "null-check@>=1.0.0 <2.0.0",
47
+ "_npmVersion": "2.7.4",
48
+ "_nodeVersion": "0.12.2",
49
+ "_npmUser": {
50
+ "name": "sindresorhus",
51
+ "email": "sindresorhus@gmail.com"
52
+ },
53
+ "dist": {
54
+ "shasum": "977dffd7176012b9ec30d2a39db5cf72a0439edd",
55
+ "tarball": "http://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz"
56
+ },
57
+ "maintainers": [
58
+ {
59
+ "name": "sindresorhus",
60
+ "email": "sindresorhus@gmail.com"
61
+ }
62
+ ],
63
+ "directories": {},
64
+ "_resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz"
65
+ }
@@ -0,0 +1,34 @@
1
+ # null-check [![Build Status](https://travis-ci.org/sindresorhus/null-check.svg?branch=master)](https://travis-ci.org/sindresorhus/null-check)
2
+
3
+ > Ensure a path doesn't contain [null bytes](http://en.wikipedia.org/wiki/Null_character)
4
+
5
+ The same check as done in all the core [`fs` methods](https://github.com/iojs/io.js/blob/18d457bd3408557a48b453f13b2b99e1ab5e7159/lib/fs.js#L88-L102).
6
+
7
+
8
+ ## Install
9
+
10
+ ```
11
+ $ npm install --save null-check
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ var nullCheck = require('null-check');
19
+
20
+ nullCheck('unicorn.png\u0000', function (err) {
21
+ console.log(err);
22
+ //=> { [Error: Path must be a string without null bytes.] code: 'ENOENT' }
23
+ });
24
+ //=> false
25
+
26
+ // the method is sync without a callback
27
+ nullCheck('unicorn.png');
28
+ //=> true
29
+ ```
30
+
31
+
32
+ ## License
33
+
34
+ MIT © [Sindre Sorhus](http://sindresorhus.com)
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "fs-access",
3
+ "version": "1.0.0",
4
+ "description": "Node.js 0.12 fs.access() & fs.accessSync() ponyfill",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/sindresorhus/fs-access"
9
+ },
10
+ "author": {
11
+ "name": "Sindre Sorhus",
12
+ "email": "sindresorhus@gmail.com",
13
+ "url": "sindresorhus.com"
14
+ },
15
+ "engines": {
16
+ "node": ">=0.10.0"
17
+ },
18
+ "scripts": {
19
+ "test": "node test.js"
20
+ },
21
+ "files": [
22
+ "index.js"
23
+ ],
24
+ "keywords": [
25
+ "built-in",
26
+ "core",
27
+ "ponyfill",
28
+ "polyfill",
29
+ "shim",
30
+ "fs",
31
+ "access",
32
+ "stat",
33
+ "mode",
34
+ "permission",
35
+ "user",
36
+ "process",
37
+ "check"
38
+ ],
39
+ "dependencies": {
40
+ "null-check": "^1.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "os-tmpdir": "^1.0.0"
44
+ },
45
+ "gitHead": "66bbcd8a8b26a4f0ccdee1cd5ea8f6256596d155",
46
+ "bugs": {
47
+ "url": "https://github.com/sindresorhus/fs-access/issues"
48
+ },
49
+ "homepage": "https://github.com/sindresorhus/fs-access",
50
+ "_id": "fs-access@1.0.0",
51
+ "_shasum": "e96872b1f415ae302bdda4ef05309eb4bde1934c",
52
+ "_from": "fs-access@>=1.0.0 <2.0.0",
53
+ "_npmVersion": "2.7.4",
54
+ "_nodeVersion": "0.12.2",
55
+ "_npmUser": {
56
+ "name": "sindresorhus",
57
+ "email": "sindresorhus@gmail.com"
58
+ },
59
+ "dist": {
60
+ "shasum": "e96872b1f415ae302bdda4ef05309eb4bde1934c",
61
+ "tarball": "http://registry.npmjs.org/fs-access/-/fs-access-1.0.0.tgz"
62
+ },
63
+ "maintainers": [
64
+ {
65
+ "name": "sindresorhus",
66
+ "email": "sindresorhus@gmail.com"
67
+ }
68
+ ],
69
+ "directories": {},
70
+ "_resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.0.tgz"
71
+ }
@@ -0,0 +1,53 @@
1
+ # fs-access [![Build Status](https://travis-ci.org/sindresorhus/fs-access.svg?branch=master)](https://travis-ci.org/sindresorhus/fs-access)
2
+
3
+ > Node.js 0.12 [`fs.access()`](https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback) & [`fs.accessSync()`](https://nodejs.org/api/fs.html#fs_fs_accesssync_path_mode) ponyfill
4
+
5
+ > Ponyfill: A polyfill that doesn't overwrite the native method
6
+
7
+
8
+ ## Install
9
+
10
+ ```
11
+ $ npm install --save fs-access
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ var fsAccess = require('fs-access');
19
+
20
+ fsAccess('unicorn.txt', function (err) {
21
+ if (err) {
22
+ console.error('no access');
23
+ return;
24
+ }
25
+
26
+ console.log('access');
27
+ });
28
+ ```
29
+
30
+ ```js
31
+ var fsAccess = require('fs-access');
32
+
33
+ try {
34
+ fsAccess.sync('unicorn.txt');
35
+ console.log('access');
36
+ } catch (err) {
37
+ console.error('no access');
38
+ }
39
+ ```
40
+
41
+
42
+ ## API
43
+
44
+ See the [`fs.access()` & `fs.accessSync()` docs](https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback).
45
+
46
+ Mode flags are on the `fsAccess` instance instead of `fs`.
47
+
48
+ Only the `F_OK` mode is supported for now. [Help welcome for additional modes.](https://github.com/sindresorhus/awesome-electron/issues/1)
49
+
50
+
51
+ ## License
52
+
53
+ MIT © [Sindre Sorhus](http://sindresorhus.com)
@@ -0,0 +1,8 @@
1
+ language: node_js
2
+ node_js:
3
+ - '0.8'
4
+ - '0.10'
5
+ - '0.12'
6
+ - 'iojs'
7
+ before_install:
8
+ - npm install -g npm@latest
@@ -0,0 +1,15 @@
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.
@@ -0,0 +1,34 @@
1
+ # which
2
+
3
+ Like the unix `which` utility.
4
+
5
+ Finds the first instance of a specified executable in the PATH
6
+ environment variable. Does not cache the results, so `hash -r` is not
7
+ needed when the PATH changes.
8
+
9
+ ## USAGE
10
+
11
+ ```javascript
12
+ var which = require('which')
13
+
14
+ // async usage
15
+ which('node', function (er, resolvedPath) {
16
+ // er is returned if no "node" is found on the PATH
17
+ // if it is found, then the absolute path to the exec is returned
18
+ })
19
+
20
+ // sync usage
21
+ // throws if not found
22
+ var resolved = which.sync('node')
23
+
24
+ // Pass options to override the PATH and PATHEXT environment vars.
25
+ which('node', { path: someOtherPath }, function (er, resolved) {
26
+ if (er)
27
+ throw er
28
+ console.log('found at %j', resolved)
29
+ })
30
+ ```
31
+
32
+ ## OPTIONS
33
+
34
+ If you pass in options, then `path` and `pathExt` are relevant.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ var which = require("../")
3
+ if (process.argv.length < 3) {
4
+ console.error("Usage: which <thing>")
5
+ process.exit(1)
6
+ }
7
+
8
+ which(process.argv[2], function (er, thing) {
9
+ if (er) {
10
+ console.error(er.message)
11
+ process.exit(er.errno || 127)
12
+ }
13
+ console.log(thing)
14
+ })
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015, Jon Schlinkert.Copyright (c) 2009-2015, TJ Holowaychuk.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.