New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsxgettext

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsxgettext - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

tests/all.js

43

lib/cli.js

@@ -53,35 +53,36 @@ #!/usr/bin/env node

var files = opts.input;
var sources = {};
if (files[0] === '-') {
var data = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
data += chunk;
});
process.stdin.on('end', function () {
gen({'stdin': data});
});
} else {
var sources = {};
files.forEach(function (filename) {
var source = fs.readFileSync(filename, "utf8");
sources[filename] = source;
sources[filename] = fs.readFileSync(filename, "utf8");
});
var result;
if (opts.language.toUpperCase() === 'EJS') {
result = jsxgettext.generateFromEJS(sources, opts);
} else {
result = jsxgettext.generate(sources, opts);
}
if (opts.output === '-') {
console.log(result);
} else {
fs.writeFileSync(path.resolve(path.join(opts['output-dir'] || '', opts.output)), result, "utf8");
}
gen(sources);
}
}
function process (source) {
}
function read (fname, cb) {
if (fname === '-') {
function gen (sources) {
var result;
if (opts.language.toUpperCase() === 'EJS') {
result = jsxgettext.generateFromEJS(sources, opts);
} else {
fs.readFileSync(fname, "utf8");
result = jsxgettext.generate(sources, opts);
}
if (opts.output === '-') {
console.log(result);
} else {
fs.writeFileSync(path.resolve(path.join(opts['output-dir'] || '', opts.output)), result, "utf8");
}
}
main();

@@ -23,3 +23,3 @@ #!/usr/bin/env node

var generated = '';
var strings = options['join-existing'] ? loadStrings(path.resolve(path.join(options['output-dir'] || '', options['output']))) : {};
var strings = options['join-existing'] ? loadStrings(path.resolve(path.join(options['output-dir'] || '', options.output))) : {};

@@ -68,7 +68,15 @@ Object.keys(sources).forEach(function (filename) {

for (var str in strings) {
// TODO start and "\n" are ugly, but
// getComment shouldn't break into multiple lines with #:
var start = true;
Object.keys(strings[str].lines).forEach(function (key) {
if (start) {
generated += "#:";
start = false;
}
var ln = strings[str].lines[key];
generated += genComment(key, ln);
});
generated += msgid(str) +
generated += "\n" +
msgid(str) +
"msgstr "+JSON.stringify(strings[str].str) + "\n" +

@@ -91,4 +99,4 @@ "\n";

function genComment (file, additional) {
return "#: " + file +
(additional ? "\n#" + additional.split("\n").join("\n#") : '') + "\n";
return " " + file +
(additional ? "\n#" + additional.split("\n").join("\n#") : '') + "";
}

@@ -126,3 +134,7 @@

function loadStrings (poFile) {
var json = parse_po(fs.readFileSync(path.resolve(poFile), "utf8"));
try {
var json = parse_po(fs.readFileSync(path.resolve(poFile), "utf8"));
} catch (e) {
return {};
}
var strings = {};

@@ -129,0 +141,0 @@

@@ -5,3 +5,3 @@ {

"description": "Extract gettext calls from JavaScript and EJS files",
"version": "0.0.2",
"version": "0.0.3",
"main": "lib/jsxgettext.js",

@@ -21,3 +21,6 @@ "bin": "lib/cli.js",

"node": "*"
},
"scripts": {
"test": "node tests/all.js"
}
}

@@ -1,2 +0,1 @@

# jsxgettext

@@ -8,2 +7,6 @@

npm install jsxgettext
Or from source:
git clone https://github.com/zaach/jsxgettext.git

@@ -10,0 +13,0 @@ cd jsxgettext

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc