This repository has been archived by the owner on May 30, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is based on http://fmarcia.info/jsmin/test.html from Franck Marcia, which in turn based on http://javascript.crockford.com/jsmin.html from Douglas Crockford.
- Loading branch information
Showing
9 changed files
with
1,130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_executable(jsmin jsmin.cpp) | ||
link_directories(${EIGHTPACK_PATH}) | ||
target_link_libraries(jsmin eightpack) | ||
set_target_properties(jsmin PROPERTIES COMPILE_FLAGS ${EIGHTPACK_COMPILE_FLAGS}) | ||
set_target_properties(jsmin PROPERTIES LINK_FLAGS ${EIGHTPACK_LINK_FLAGS}) | ||
install(TARGETS jsmin DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*global system: true, console: true */ | ||
var jsmin, fname, settings, level, code, result; | ||
|
||
settings = settings || {}; | ||
|
||
function help() { | ||
'use strict'; | ||
var opt, str; | ||
console.log('Usage:'); | ||
console.log(' jsmin [options] filename'); | ||
console.log(); | ||
console.log('The content of filename will be minified and printed to'); | ||
console.log('standard output.'); | ||
console.log(); | ||
console.log('General options:'); | ||
console.log(' --help Show this help screen'); | ||
console.log(' --version Display version number'); | ||
console.log(); | ||
console.log('JSMin options (see http://fmarcia.info/jsmin/test.html):'); | ||
for (opt in settings) { | ||
if (settings.hasOwnProperty(opt)) { | ||
str = ' --' + opt; | ||
while (str.length < 25) { | ||
str += ' '; | ||
} | ||
str += settings[opt]; | ||
console.log(str); | ||
} | ||
} | ||
console.log(); | ||
console.log('For more information, go to http://fmarcia.info/jsmin/test.html and'); | ||
console.log('http://www.crockford.com/javascript/jsmin.html.'); | ||
console.log(); | ||
system.exit(-1); | ||
} | ||
|
||
if (system.args.length < 1) { | ||
help(); | ||
} | ||
|
||
level = 2; | ||
|
||
system.args.forEach(function (arg) { | ||
'use strict'; | ||
var option, i; | ||
if (arg.length > 2) { | ||
if (arg.charAt(0) === '-' && arg.charAt(1) === '-') { | ||
option = arg.substring(2, arg.length); | ||
|
||
if (option === 'help') { | ||
help(); | ||
} | ||
|
||
if (option === 'version') { | ||
console.log('jsmin.js edition 2010/01/15.'); | ||
system.exit(-1); | ||
} | ||
|
||
if (!settings.hasOwnProperty(option)) { | ||
console.log('Unknown option: --' + option); | ||
console.log('Run jsmin --help to list all possible options.'); | ||
console.log(); | ||
system.exit(-1); | ||
} | ||
|
||
if (option === 'aggressive') { | ||
level = 3; | ||
} | ||
|
||
if (option === 'minimal') { | ||
level = 1; | ||
} | ||
|
||
return; | ||
} | ||
} | ||
if (typeof fname !== 'undefined') { | ||
console.log('Please only specify one filename!'); | ||
console.log(); | ||
system.exit(-1); | ||
} | ||
fname = arg; | ||
}); | ||
|
||
|
||
if (typeof fname === 'undefined') { | ||
help(); | ||
} | ||
|
||
try { | ||
code = system.readFile(fname); | ||
result = jsmin('', code, level); | ||
console.log(result); | ||
} catch (e) { | ||
console.log(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var settings = { | ||
'conversative': 'The default, removes comments and unnecessary whitespace.', | ||
'minimal': 'Like conversative but keeps single linefeeds.', | ||
'aggressive': 'Like conversative but removes more linefeeds (dangerous!)', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Copyright (C) 2011 Ariya Hidayat. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
|
||
#include "jsmin_script.h" | ||
|
||
extern void eightpack_run(int argc, char** argv, const char* cmd); | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
eightpack_run(argc, argv, jsmin_script); | ||
return 0; | ||
} | ||
|
Oops, something went wrong.