Skip to content

Commit c546120

Browse files
committed
Require Node.js 8
1 parent 881d1c4 commit c546120

File tree

6 files changed

+27
-38
lines changed

6 files changed

+27
-38
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
language: node_js
22
node_js:
3+
- '12'
4+
- '10'
35
- '8'
4-
- '6'
5-
- '4'
6-
- '0.12'
7-
- '0.10'

index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
'use strict';
2-
var shebangRegex = require('shebang-regex');
2+
const shebangRegex = require('shebang-regex');
33

4-
module.exports = function (str) {
5-
var match = str.match(shebangRegex);
4+
module.exports = (string = '') => {
5+
const match = string.match(shebangRegex);
66

77
if (!match) {
88
return null;
99
}
1010

11-
var arr = match[0].replace(/#! ?/, '').split(' ');
12-
var bin = arr[0].split('/').pop();
13-
var arg = arr[1];
11+
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
12+
const binary = path.split('/').pop();
1413

15-
return (
16-
bin === 'env' ?
17-
arg :
18-
bin + (arg ? ' ' + arg : '')
19-
);
14+
if (binary === 'env') {
15+
return argument;
16+
}
17+
18+
return argument ? `${binary} ${argument}` : binary;
2019
};

package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "github.com/kevva"
1111
},
1212
"engines": {
13-
"node": ">=0.10.0"
13+
"node": ">=8"
1414
},
1515
"scripts": {
1616
"test": "xo && ava"
@@ -25,13 +25,10 @@
2525
"shebang"
2626
],
2727
"dependencies": {
28-
"shebang-regex": "^1.0.0"
28+
"shebang-regex": "^3.0.0"
2929
},
3030
"devDependencies": {
31-
"ava": "^0.17.0",
32-
"xo": "^0.16.0"
33-
},
34-
"xo": {
35-
"esnext": false
31+
"ava": "^2.3.0",
32+
"xo": "^0.24.0"
3633
}
3734
}

readme.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,3 @@ shebangCommand('#!/bin/bash');
3232
Type: `string`
3333

3434
String containing a shebang.
35-
36-
37-
## License
38-
39-
MIT © [Kevin Mårtensson](https://github.com/kevva)

test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import test from 'ava';
2-
import fn from './';
2+
import shebangCommand from '.';
33

4-
test(t => {
5-
t.is(fn('#!/usr/bin/env node'), 'node');
6-
t.is(fn('#!/bin/bash'), 'bash');
7-
t.is(fn('#!/bin/bash -ex'), 'bash -ex');
8-
t.is(fn('#! /bin/bash'), 'bash');
9-
t.is(fn('#! /bin/bash -ex'), 'bash -ex');
10-
t.is(fn('#!/sh'), 'sh');
11-
t.is(fn('node'), null);
4+
test('main', t => {
5+
t.is(shebangCommand('#!/usr/bin/env node'), 'node');
6+
t.is(shebangCommand('#!/bin/bash'), 'bash');
7+
t.is(shebangCommand('#!/bin/bash -ex'), 'bash -ex');
8+
t.is(shebangCommand('#! /bin/bash'), 'bash');
9+
t.is(shebangCommand('#! /bin/bash -ex'), 'bash -ex');
10+
t.is(shebangCommand('#!/sh'), 'sh');
11+
t.is(shebangCommand('node'), null);
12+
t.is(shebangCommand(), null);
1213
});

0 commit comments

Comments
 (0)