File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ module.exports = {
14
14
CHAR_COLON : 58 , /* : */
15
15
CHAR_QUESTION_MARK : 63 , /* ? */
16
16
CHAR_UNDERSCORE : 95 , /* _ */
17
+ CHAR_LINE_FEED : 10 , /* \n */
18
+ CHAR_CARRIAGE_RETURN : 13 , /* \r */
19
+ CHAR_EXCLAMATION_MARK : 33 , /* ! */
20
+ CHAR_HASH : 35 , /* # */
17
21
18
22
// Digits
19
23
CHAR_0 : 48 , /* 0 */
Original file line number Diff line number Diff line change 2
2
3
3
const errors = require ( 'internal/errors' ) ;
4
4
5
+ const {
6
+ CHAR_LINE_FEED ,
7
+ CHAR_CARRIAGE_RETURN ,
8
+ CHAR_EXCLAMATION_MARK ,
9
+ CHAR_HASH ,
10
+ } = require ( 'internal/constants' ) ;
11
+
5
12
// Invoke with makeRequireFunction(module) where |module| is the Module object
6
13
// to use as the context for the require() function.
7
14
function makeRequireFunction ( mod ) {
@@ -65,8 +72,8 @@ function stripShebang(content) {
65
72
// Remove shebang
66
73
var contLen = content . length ;
67
74
if ( contLen >= 2 ) {
68
- if ( content . charCodeAt ( 0 ) === 35 /*#*/ &&
69
- content . charCodeAt ( 1 ) === 33 /*!*/ ) {
75
+ if ( content . charCodeAt ( 0 ) === CHAR_HASH &&
76
+ content . charCodeAt ( 1 ) === CHAR_EXCLAMATION_MARK ) {
70
77
if ( contLen === 2 ) {
71
78
// Exact match
72
79
content = '' ;
@@ -75,7 +82,7 @@ function stripShebang(content) {
75
82
var i = 2 ;
76
83
for ( ; i < contLen ; ++ i ) {
77
84
var code = content . charCodeAt ( i ) ;
78
- if ( code === 10 /*\n*/ || code === 13 /*\r*/ )
85
+ if ( code === CHAR_LINE_FEED || code === CHAR_CARRIAGE_RETURN )
79
86
break ;
80
87
}
81
88
if ( i === contLen )
You can’t perform that action at this time.
0 commit comments