Skip to content

Commit

Permalink
use js-beautify as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy committed Jan 5, 2015
1 parent 6357cd5 commit 50416f6
Show file tree
Hide file tree
Showing 123 changed files with 13,716 additions and 8 deletions.
40 changes: 32 additions & 8 deletions lisp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ else if (argv.length === 3){
console.log("No input file ... ");
process.exit(0);
}
if(file_name.length <= 5 ||
(file_name.slice(-5) !== ".lisp")){
console.log("Invalid file name\nPlz use .lisp format. eg test.lisp");
process.exit(0);
}
// get content of file.
var content_in_file = fs.readFileSync(file_name, "utf8");
var compiled_result = lisp.compile(content_in_file);
Expand Down Expand Up @@ -98,12 +103,31 @@ else if (argv.length === 4){
vm.runInThisContext(compiled_result, "lisp.vm"); // now running in global

var save_to_file = argv[3]// file_name.slice(-5) + ".js";
fs.writeFile(save_to_file, compiled_result, function(error){
if(error){
console.log(error)
}
else{
console.log("File: " + save_to_file + " saved!");
}
})

// if has js-beautify installed
try{
var beautify = require("js-beautify").js_beautify;
var res = beautify(compiled_result);
fs.writeFile(save_to_file, res, function(error){
if(error){
console.log(error)
}
else{
console.log("File: " + save_to_file + " saved!");
}
})
}
catch(e){
console.log("\n\n\n");
console.log(e);
console.log("You need to install js-beautify to see beautified result\nsee https://www.npmjs.com/package/js-beautify for more information\n\n\n");
fs.writeFile(save_to_file, compiled_result, function(error){
if(error){
console.log(error)
}
else{
console.log("File: " + save_to_file + " saved!");
}
})
}
}
1 change: 1 addition & 0 deletions node_modules/.bin/css-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/html-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-beautify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node_modules/js-beautify/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions node_modules/js-beautify/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

279 changes: 279 additions & 0 deletions node_modules/js-beautify/CHANGELOG.md

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions node_modules/js-beautify/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/js-beautify/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

187 changes: 187 additions & 0 deletions node_modules/js-beautify/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/js-beautify/bower.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 50416f6

Please sign in to comment.