FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gulp-javascript-obfuscator/index.js at master · javascript-obfuscator/gulp-javascript-obfuscator · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
javascript-obfuscator
/
gulp-javascript-obfuscator
Public
Notifications
You must be signed in to change notification settings
Fork
37
Star
103
Code
Issues
13
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gulp-javascript-obfuscator
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (38 loc) · 1.34 KB
Breadcrumbs
gulp-javascript-obfuscator
/
index.js
Copy path
File metadata and controls
40 lines (38 loc) · 1.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const
through2
=
require
(
'through2'
)
;
const
Vinyl
=
require
(
'vinyl'
)
;
const
JavaScriptObfuscator
=
require
(
'javascript-obfuscator'
)
;
const
PluginError
=
require
(
'plugin-error'
)
;
const
applySourceMap
=
require
(
'vinyl-sourcemaps-apply'
)
;
module
.
exports
=
function
gulpJavaScriptObfuscator
(
options
=
{
}
)
{
return
through2
.
obj
(
function
(
file
,
enc
,
cb
)
{
if
(
file
.
isNull
(
)
)
return
cb
(
null
,
file
)
;
if
(
!
file
.
isBuffer
(
)
)
throw
new
PluginError
(
'gulp-javascript-obfuscator'
,
'Only Buffers are supported!'
)
;
if
(
file
.
sourceMap
)
{
options
.
sourceMap
=
true
;
options
.
inputFileName
=
file
.
relative
;
options
.
sourceMapMode
=
'separate'
;
}
try
{
const
obfuscationResult
=
JavaScriptObfuscator
.
obfuscate
(
String
(
file
.
contents
)
,
options
)
;
file
.
contents
=
new
Buffer
(
obfuscationResult
.
getObfuscatedCode
(
)
)
;
if
(
options
.
sourceMap
&&
options
.
sourceMapMode
!==
'inline'
)
{
if
(
file
.
sourceMap
)
{
const
sourceMap
=
JSON
.
parse
(
obfuscationResult
.
getSourceMap
(
)
)
;
sourceMap
.
file
=
file
.
sourceMap
.
file
;
applySourceMap
(
file
,
sourceMap
)
;
}
else
{
this
.
push
(
new
Vinyl
(
{
cwd
:
file
.
cwd
,
base
:
file
.
base
,
path
:
file
.
path
+
'.map'
,
contents
:
new
Buffer
(
obfuscationResult
.
getSourceMap
(
)
)
}
)
)
}
}
return
cb
(
null
,
file
)
;
}
catch
(
err
)
{
throw
new
PluginError
(
'gulp-javascript-obfuscator'
,
err
)
;
}
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL