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)
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);
}
duration: track.duration_ms,
popularity: track.popularity,
preview: track.preview_url,
albumArtwork: _.max(track.album.images, function(d) { return d.width; }).url
});
},
function(err) { return reject(err); }
);
});
}
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);
}
return new Promise(function(resolve, reject) {
if (fs.existsSync(fname)) {
console.log(' - cache hit for', hash);
resolve(rw.readFileSync(fname, 'utf8'));
} else {
console.log(' - cache miss for', hash);
makeRequest(url, fname, resolve, reject);
}
});
}
var trackData = JSON.parse(trackResponse);
var genres = utils
.getIn(trackData, ['message','body','track','primary_genres', 'music_genre_list'])
.map(function(d) { return utils.getIn(d, ['music_genre', 'music_genre_name']); });
version.musiXmatch = {
id: mmId,
genres: genres
};
return callback(null, version);
}).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);
}