gonzales.js 594 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env node
  2. /**
  3. * ./bin/gonzales.js filename
  4. * ./bin/gonzales.js filename -s
  5. */
  6. var gonzales = require('..'),
  7. fs = require('fs'),
  8. path = require('path'),
  9. filename = process.argv[2],
  10. silent = process.argv[3] === '-s';
  11. if (!filename) {
  12. console.log('Please supply a filename. Usage "gonzales file"');
  13. process.exit();
  14. }
  15. var syntax = path.extname(filename).substring(1);
  16. var css = fs.readFileSync(filename, 'utf-8');
  17. try {
  18. var ast = gonzales.parse(css, {syntax: syntax});
  19. if (!silent) console.log(ast.toString());
  20. } catch (e) {
  21. if (!silent) throw e;
  22. }