summaryrefslogtreecommitdiffstats
path: root/node_modules/xss/bin
diff options
context:
space:
mode:
authorAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-02-08 16:41:06 +0100
committerAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-02-08 16:41:06 +0100
commitf87697e22f289cc96fc4e79da81575115b3e89a2 (patch)
tree57870d84a853db60c80e254beb423c838d910fbe /node_modules/xss/bin
parentchanged version to 1.0.7-beta (diff)
downloadbeziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar.gz
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar.bz2
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar.lz
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar.xz
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.tar.zst
beziapp-f87697e22f289cc96fc4e79da81575115b3e89a2.zip
Diffstat (limited to 'node_modules/xss/bin')
-rwxr-xr-xnode_modules/xss/bin/xss67
1 files changed, 67 insertions, 0 deletions
diff --git a/node_modules/xss/bin/xss b/node_modules/xss/bin/xss
new file mode 100755
index 0000000..35e902f
--- /dev/null
+++ b/node_modules/xss/bin/xss
@@ -0,0 +1,67 @@
+#!/usr/bin/env node
+
+/**
+ * 命令行工具
+ *
+ * @author Zongmin Lei<leizongmin@gmail.com>
+ */
+
+var fs = require('fs');
+var path = require('path');
+var program = require('commander');
+var xss = require('../');
+var packageInfo = require('../package.json');
+
+program
+ .version(packageInfo.version)
+ .option('-t, --test', 'active test')
+ .option('-i, --input <input_file>', 'input file name')
+ .option('-o, --output <output_file>', 'output filename')
+ .option('-c, --config <config_file>', 'load custom config')
+ .option('-s, --strip-ignore-tag', 'set stripIgnoreTag=true')
+ .option('-b, --strip-ignore-tag-body', 'set stripIgnoreTagBody=true');
+
+program.on('--help', function () {
+ console.log(' Examples:');
+ console.log('');
+ console.log(' $ xss -t');
+ console.log(' $ xss -i origin.html');
+ console.log(' $ xss -i origin.html -o targer.html');
+ console.log(' $ xss -i origin.html -c config.js');
+ console.log(' $ xss -i origin.html -s');
+ console.log(' $ xss -i origin.html -s -b');
+ console.log('');
+ console.log(' For more details, please see: https://npmjs.org/package/xss')
+});
+
+program.parse(process.argv);
+
+if (program.test) {
+ require('../lib/cli');
+ return;
+}
+
+var config = {};
+if (program.config) {
+ config = require(path.resolve(program.config));
+}
+if (program.input) {
+ var input = fs.readFileSync(program.input, 'utf8');
+} else {
+ program.help();
+}
+
+if (program['strip-ignore-tag']) {
+ config.stripIgnoreTag = true;
+}
+if (program['strip-ignore-tag-body']) {
+ config.stripIgnoreTagBody = true;
+}
+
+var output = xss(input, config);
+
+if (program.output) {
+ fs.writeFileSync(program.output, output);
+} else {
+ console.log(output);
+}