File tree Expand file tree Collapse file tree 6 files changed +27
-38
lines changed Expand file tree Collapse file tree 6 files changed +27
-38
lines changed Original file line number Diff line number Diff line change 1
- * text =auto
2
- * .js text eol =lf
1
+ * text =auto eol =lf
Original file line number Diff line number Diff line change 1
1
language : node_js
2
2
node_js :
3
+ - ' 12'
4
+ - ' 10'
3
5
- ' 8'
4
- - ' 6'
5
- - ' 4'
6
- - ' 0.12'
7
- - ' 0.10'
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
- var shebangRegex = require ( 'shebang-regex' ) ;
2
+ const shebangRegex = require ( 'shebang-regex' ) ;
3
3
4
- module . exports = function ( str ) {
5
- var match = str . match ( shebangRegex ) ;
4
+ module . exports = ( string = '' ) => {
5
+ const match = string . match ( shebangRegex ) ;
6
6
7
7
if ( ! match ) {
8
8
return null ;
9
9
}
10
10
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 ( ) ;
14
13
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 ;
20
19
} ;
Original file line number Diff line number Diff line change 10
10
"url" : " github.com/kevva"
11
11
},
12
12
"engines" : {
13
- "node" : " >=0.10.0 "
13
+ "node" : " >=8 "
14
14
},
15
15
"scripts" : {
16
16
"test" : " xo && ava"
25
25
" shebang"
26
26
],
27
27
"dependencies" : {
28
- "shebang-regex" : " ^1 .0.0"
28
+ "shebang-regex" : " ^3 .0.0"
29
29
},
30
30
"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"
36
33
}
37
34
}
Original file line number Diff line number Diff line change @@ -32,8 +32,3 @@ shebangCommand('#!/bin/bash');
32
32
Type: ` string `
33
33
34
34
String containing a shebang.
35
-
36
-
37
- ## License
38
-
39
- MIT © [ Kevin Mårtensson] ( https://github.com/kevva )
Original file line number Diff line number Diff line change 1
1
import test from 'ava' ;
2
- import fn from './ ' ;
2
+ import shebangCommand from '.' ;
3
3
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 ) ;
12
13
} ) ;
You can’t perform that action at this time.
0 commit comments