remove dependencies

This commit is contained in:
Aleksey Chichenkov 2019-01-30 18:03:10 +03:00
parent a7873cc203
commit 8f914cc2d9
9 changed files with 3266 additions and 2052 deletions

View File

@ -6,8 +6,6 @@
## Compile lemon-js
```bash
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
# or
./build.sh
```
@ -90,3 +88,7 @@ Used re2js lexer from: [http://git.macaw.me:3000/chichenkov/re2-js-generator](ht
## Original project
See https://github.com/sormy/lemon-js
## Links
- Used js-beautify-node from: [https://github.com/rwaldron/js-beautify-node](https://github.com/rwaldron/js-beautify-node)
- Used args-parser from: [https://www.npmjs.com/package/args-parser](https://www.npmjs.com/package/args-parser)

View File

@ -2,8 +2,6 @@
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
cat config.example > config.js
node main.js

View File

@ -2,6 +2,4 @@
gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
npm install
cat config.template > config.js

File diff suppressed because it is too large Load Diff

41
libs/args-parser.js Normal file
View File

@ -0,0 +1,41 @@
/**
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/30/19.
*/
function Parse (argv) {
// Removing node/bin and called script name
argv = argv.slice(2);
// Returned object
var args = {};
var argName, argValue;
// For each argument
argv.forEach(function (arg, index) {
// Seperate argument, for a key/value return
arg = arg.split('=');
// Retrieve the argument name
argName = arg[0];
// Remove "--" or "-"
if (argName.indexOf('-') === 0) {
argName = argName.slice(argName.slice(0, 2).lastIndexOf('-') + 1);
}
// Associate defined value or initialize it to "true" state
argValue = (arg.length === 2)
? parseFloat(arg[1]).toString() === arg[1] // check if argument is valid number
? +arg[1]
: arg[1]
: true;
// Finally add the argument to the args set
args[argName] = argValue;
});
return args;
}
module.exports = Parse;

1179
libs/js-beautifier.js Normal file

File diff suppressed because it is too large Load Diff

13
main.js
View File

@ -2,8 +2,8 @@
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/28/19.
*/
var js_beautify = require("js-beautify");
var args = require("args-parser")(process.argv);
var js_beautify = require("./libs/js-beautifier");
var args = require("./libs/args-parser")(process.argv);
var fs = require("fs");
var exec = require('child_process').exec;
@ -55,7 +55,14 @@ var post_process_parser = function () {
}
}
out_js = js_beautify(out_js, {indent_size: 4, space_in_empty_paren: true});
out_js = js_beautify(out_js, {
indent_size: 4,
indent_char: ' ',
preserve_newlines: true,
space_after_anon_function: true,
keep_array_indentation: false,
braces_on_own_line: false
});
if(!fs.existsSync(output_path)){
fs.mkdirSync(output_path);

View File

@ -7,8 +7,5 @@
"name": "chichenkov",
"email": "rolahd@yandex.ru"
},
"dependencies": {
"args-parser": "^1.1.0",
"js-beautify": "^1.8.9"
}
"dependencies": {}
}

View File

@ -4,7 +4,7 @@
var fs = require("fs");
var exec = require('child_process').exec;
var args = require("args-parser")(process.argv);
var args = require("./libs/args-parser")(process.argv);
var cfg_path = "config.js";
var config;