Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
.parse(process.argv);
// Display help information by default
if (!process.argv.slice(2).length) {
athena.outputHelp();
}
if (!uriArg) {
console.error("No URI given. Set the URI to `-` to pipe HTML via stdin.");
process.exit(1);
}
// Handle stdin
if (uriArg === "-") {
let base64Html = new Buffer(rw.readFileSync("/dev/stdin", "utf8"), "utf8").toString("base64");
uriArg = "data:text/html;base64," + base64Html;
// Handle local paths
} else if (!uriArg.toLowerCase().startsWith("http") && !uriArg.toLowerCase().startsWith("chrome://")) {
uriArg = url.format({
protocol: "file",
pathname: path.resolve(uriArg),
slashes: true
});
}
// Generate SHA1 hash if no output is specified
if (!outputArg) {
const shasum = crypto.createHash("sha1");
shasum.update(uriArg);
outputArg = shasum.digest("hex") + ".pdf";
}
// callback(null, _.extend(version, {echonest: echonest}));
//}
})
.catch(callback);
})
.catch(callback);
}
var works = JSON.parse(rw.readFileSync(INPUT_WORKS, 'utf8'));
if (LIMIT_WORKS) {
works = _.take(works, LIMIT_WORKS);
}
var worksRequests = works.map(function(work) {
console.log('Processing work "' + work.title + '". Found ' + work.versions.length + ' versions');
return new Promise(function (resolveWork, rejectWork) {
var versions = work.versions;
if (LIMIT_VERSIONS) {
versions = _.take(versions, LIMIT_VERSIONS);
}
});
Promise
.all(pageRequests)
.then(function(data) {
callback(null, covers.concat(_.flatten(data)));
}, callback);
}, callback);
}
// I couldn't get the above stuff to work, so it's not used
// (but kept here in case it can be made to work)
// Instead, I wrote a script to read a list of pre-resolved urls
// that script starts here
var works = JSON.parse(rw.readFileSync(INPUT_FILE, 'utf8'));
var oUrls = [];
works.forEach(function(work) {
work.versions.forEach(function(version) {
if (version.echonest && version.echonest.whosampledId) {
oUrls.push(BASE_URL + '/track/view/' + version.echonest.whosampledId)
}
})
})
function shiftAndResolve(list1, list2, callback) {
var u = list1.shift();
console.log('checking, ', u);
resolver.resolve(u, function(err, url) {
if (!err) list2.push(url)
if (program.watch === true || program.suites === true || program.tests === true) {
process.stderr.write(chalk.red("Error: This feature is not currently implemented"));
return;
}
process.stdout.write(summaryStr);
// console.log(program);
var done = function() {
process.stdout.write("\n### DONE ###");
};
var outPath = program.out ? program.out : "/dev/stdout";
if (program.out) resultStr = resultStr.replace(/\[\d+m/g, "");
if (program.json === true) {
rw.writeFileSync(outPath, JSON.stringify(results), "utf-8");
done();
return;
}
if (program.jsonPretty === true) {
rw.writeFileSync(outPath, JSON.stringify(results, null, 2), "utf-8");
done();
return;
}
if (program.summary !== true) {
rw.writeFileSync(outPath, resultStr, "utf-8");
done();
return;
}
} else {
process.stderr.write(
chalk.red("Error: Must use a supported filetype. Currently supported filetypes: " + allowFileExtensions.join(", "), "utf-8")
#!/usr/bin/env node
const rw = require('rw').dash
const prettier = require('prettier')
const stringify = require('json-stable-stringify')
// https://github.com/prettier/prettier/tree/a707dda53b13a6956a825609f30baead7ef08a59#api
const prettierOptions = {
printWidth: 80,
tabWidth: 2,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true
}
const content = rw.readFileSync(process.argv[2] || '-').toString()
let pretty = content
// try to format JS files
#!/usr/bin/env node
const rw = require('rw').dash
const prettier = require('prettier')
const stringify = require('json-stable-stringify')
// https://github.com/prettier/prettier/tree/a707dda53b13a6956a825609f30baead7ef08a59#api
const prettierOptions = {
printWidth: 80,
tabWidth: 2,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true
}
const content = rw.readFileSync(process.argv[2] || '-').toString()
let pretty = content
// try to format JS files
try {
pretty = prettier.format(content, prettierOptions)
} catch (err) {}
// try to format JSON files
// prettier doesn't do this currently: https://github.com/prettier/prettier/issues/322
try {
const sorted = stringify(JSON.parse(content), {
space: prettierOptions.tabWidth
})
// Put a comma after strings, numbers, objects, arrays, `true`, `false`, or
// `null` at the end of a line. See the grammar at http://json.org/
pretty = sorted.replace(/(.["\d}\]el])$/gm, '$1,')
console.log("Transforms nodes for translation. Reads/writes to stdin/out.");
process.exit();
}
if (process.argv.length != 2
|| ~process.argv.indexOf("-h")
|| ~process.argv.indexOf("--help")) {
showHelpAndExit();
}
var rw = require('rw');
var jsxlate = require('../lib/jsxlate.js');
var input = rw.readFileSync("/dev/stdin", "utf8");
try {
console.log(jsxlate.transformMessageNodes(input));
} catch (e) {
console.error(jsxlate.errorMessageForError(e));
process.exit(1);
}
if (process.argv.length != 4
|| process.argv[2] != "-t"
|| ~process.argv.indexOf("-h")
|| ~process.argv.indexOf("--help")) {
showHelpAndExit();
}
var rw = require('rw');
var jsxlate = require('../lib/jsxlate.js');
var translationsFilename = process.argv[3];
var translations = JSON.parse(rw.readFileSync(translationsFilename, "utf8"));
var input = rw.readFileSync("/dev/stdin", "utf8");
try {
console.log(jsxlate.translateMessages(input, translations));
} catch (e) {
console.error(jsxlate.errorMessageForError(e));
process.exit(1);
}
var chalk = require('chalk');
var fs = require('fs');
var rw = require('rw');
var io = require('../build/io').default;
var filesFromMixedPaths = require('./filesFromMixedPaths');
var translateMessagesToBundle = require('../build/translate').default;
if (argv.f) {
var format = argv.f;
} else {
var fileChunks = argv.t.split('.');
var format = fileChunks[fileChunks.length - 1];
}
var translations = rw.readFileSync(argv.t, "utf8");
var files = filesFromMixedPaths(argv._);
var bundle = {};
var missing = {};
files.forEach(function (filename) {
var buffer = fs.readFileSync(filename, "utf8");
try {
var translationsForFile = translateMessagesToBundle(buffer, translations, { inputFormat: format });
} catch (e) {
console.error(chalk.bold.red("\nError in file " + filename + ":"));
console.error(e);
console.error(e.stack);
e.node && console.error(generate(e.node));
process.exit(1);
}
}
if (process.argv.length != 4
|| process.argv[2] != "-t"
|| ~process.argv.indexOf("-h")
|| ~process.argv.indexOf("--help")) {
showHelpAndExit();
}
var rw = require('rw');
var jsxlate = require('../lib/jsxlate.js');
var translationsFilename = process.argv[3];
var translations = JSON.parse(rw.readFileSync(translationsFilename, "utf8"));
var input = rw.readFileSync("/dev/stdin", "utf8");
try {
console.log(jsxlate.translateMessages(input, translations));
} catch (e) {
console.error(jsxlate.errorMessageForError(e));
process.exit(1);
}