Skip to content

Commit e78250a

Browse files
committed
chore: add support down to v0.11
This only performs linting for v4+, however, since that's the limit for eslint. This should be fine, since we really only need to run linting once per pull request anyway.
1 parent bf5d7ae commit e78250a

5 files changed

Lines changed: 32 additions & 6 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
language: c++
22
sudo: false
33
env:
4+
- NODE_VERSION="0.11"
5+
- NODE_VERSION="0.12"
6+
- NODE_VERSION="1"
7+
- NODE_VERSION="2"
8+
- NODE_VERSION="3"
49
- NODE_VERSION="4"
510
- NODE_VERSION="5"
611
- NODE_VERSION="6"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ shell.open('file.txt'); // the plugin is now available!
6161
- OS X
6262
- Windows
6363

64-
This is only supported for Node v4+
64+
This is supported for Node v0.11+
6565

6666
## Writing plugins
6767

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@ var plugin = require('shelljs/plugin');
33

44
// Require whatever modules you need for your project
55
var opener = require('opener');
6-
var pathExists = require('path-exists');
6+
var fs = require('fs');
7+
var pathExistsSync = function (filePath) {
8+
try {
9+
fs.accessSync(filePath);
10+
return true;
11+
} catch (e) {
12+
return false;
13+
}
14+
};
715

816
// Implement your command in a function, which accepts `options` as the
917
// first parameter, and other arguments after that
1018
function open(options, fileName) {
1119
var URL_REGEX = /^https?:\/\/.*/;
1220

13-
if (!pathExists.sync(fileName) && !fileName.match(URL_REGEX)) {
21+
if (!pathExistsSync(fileName) && !fileName.match(URL_REGEX)) {
1422
plugin.error('Unable to locate file: ' + fileName);
1523
}
1624

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"posttest": "npm run lint",
88
"test": "mocha",
9-
"lint": "eslint .",
9+
"lint": "node scripts/eslint-wrapper.js",
1010
"changelog": "shelljs-changelog",
1111
"release:major": "shelljs-release major",
1212
"release:minor": "shelljs-release minor",
@@ -40,7 +40,6 @@
4040
"shelljs": "^0.7.3"
4141
},
4242
"dependencies": {
43-
"opener": "^1.4.1",
44-
"path-exists": "^3.0.0"
43+
"opener": "^1.4.1"
4544
}
4645
}

scripts/eslint-wrapper.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
3+
var exec = require('child_process').exec;
4+
5+
// var version = process.version;
6+
var version = process.version.substr(1).split('.');
7+
if (parseInt(version[0], 10) >= 4) {
8+
exec('eslint .', { stdio: 'inherit' }, function (code) {
9+
process.exit(code);
10+
});
11+
} else {
12+
console.log('Linting is only supported on node v4+');
13+
process.exit(0);
14+
}

0 commit comments

Comments
 (0)