Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "js-gettext", | ||
"version": "1.0.1", | ||
"description": "gettext alternative for js", | ||
"main": "index.js", | ||
"author": "Pedro Ladaria <pedro.ladaria@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "ava tests" | ||
}, | ||
"dependencies": { | ||
"glob": "^7.1.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.22.0" | ||
}, | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pladaria/js-gettext.git" | ||
}, | ||
"keywords": [ | ||
"gettext", | ||
"token", | ||
"extractor", | ||
"i18n", | ||
"translations", | ||
"internationalization", | ||
"translate" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/pladaria/js-gettext/issues" | ||
}, | ||
"homepage": "https://github.com/pladaria/js-gettext#readme" | ||
"name": "js-gettext", | ||
"version": "1.0.2", | ||
"description": "gettext alternative for js", | ||
"main": "./src/index.js", | ||
"author": "Pedro Ladaria <pedro.ladaria@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "ava tests", | ||
"precommit": "lint-staged" | ||
}, | ||
"bin": { | ||
"js-gettext": "./src/index.js" | ||
}, | ||
"dependencies": { | ||
"commander": "^2.11.0", | ||
"glob": "^7.1.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.22.0", | ||
"eslint": "^4.8.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^4.2.3", | ||
"prettier": "^1.7.4" | ||
}, | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pladaria/js-gettext.git" | ||
}, | ||
"keywords": [ | ||
"gettext", | ||
"token", | ||
"extractor", | ||
"i18n", | ||
"translations", | ||
"internationalization", | ||
"translate" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/pladaria/js-gettext/issues" | ||
}, | ||
"homepage": "https://github.com/pladaria/js-gettext#readme", | ||
"prettier": { | ||
"printWidth": 100, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"bracketSpacing": false | ||
}, | ||
"lint-staged": { | ||
"gitDir": "./", | ||
"linters": { | ||
"*.js": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
} | ||
} | ||
} |
@@ -1,6 +0,5 @@ | ||
const {readdirSync, readFileSync, statSync} = require('fs'); | ||
const {readFileSync, statSync} = require('fs'); | ||
const glob = require('glob'); | ||
const {buildFunctionCallRegExp} = require('./regular-expressions'); | ||
const readParameters = require('./read-parameters'); | ||
const gettextFormatter = require('./formatters/gettext'); | ||
@@ -14,3 +13,3 @@ const addToken = (tokens, filename, line, token, tokenPlural = '') => { | ||
positions: [`${filename}:${line}`], | ||
} | ||
}; | ||
} else { | ||
@@ -26,3 +25,3 @@ tokens[key].positions.push(`${filename}:${line}`); | ||
} | ||
}; | ||
} | ||
return tokens; | ||
@@ -38,3 +37,3 @@ }; | ||
line++; | ||
} else if (match = text.substr(i).match(RE_SINGULAR)) { | ||
} else if ((match = text.substr(i).match(reSingular))) { | ||
i += match[0].length; | ||
@@ -48,3 +47,3 @@ const {params, length} = readParameters(text.substr(i), 1); | ||
} | ||
} else if (match = text.substr(i).match(RE_PLURAL)) { | ||
} else if ((match = text.substr(i).match(rePlural))) { | ||
i += match[0].length; | ||
@@ -62,5 +61,5 @@ const {params, length} = readParameters(text.substr(i), 2); | ||
module.exports = ({path, ignore, singular, plural}) => { | ||
const files = glob.sync(path, {ignore}); | ||
const tokens = {} | ||
module.exports = ({input, ignore, singular, plural, verbose}) => { | ||
const files = glob.sync(input, {ignore}); | ||
const tokens = {}; | ||
const reSingular = buildFunctionCallRegExp(singular); | ||
@@ -70,2 +69,5 @@ const rePlural = buildFunctionCallRegExp(plural); | ||
files.forEach(f => { | ||
if (verbose) { | ||
console.error(f); | ||
} | ||
const stat = statSync(f); | ||
@@ -72,0 +74,0 @@ if (stat.isFile()) { |
/** | ||
* JSON formatter | ||
*/ | ||
module.exports = (tokens, { | ||
replacer = null, | ||
space = ' ', | ||
}) => JSON.stringify(tokens, replacer, space); | ||
module.exports = (tokens, {replacer = null, space = ' '} = {}) => | ||
JSON.stringify(tokens, replacer, space); |
@@ -59,2 +59,3 @@ /** | ||
} | ||
break; | ||
default: | ||
@@ -61,0 +62,0 @@ if (state === 'string') { |
@@ -5,6 +5,7 @@ /** | ||
*/ | ||
module.exports.buildFunctionCallRegExp = s => RegExp( | ||
'^' + // beginning of the string | ||
s.replace(/\./g, '\\s*\\.\\s*') + // dot can be surrounded by whitespaces | ||
'\\s*\\(\\s*' // opening parenthesis can be surrounded by whitespaces | ||
); | ||
module.exports.buildFunctionCallRegExp = s => | ||
RegExp( | ||
'^' + // beginning of the string | ||
s.replace(/\./g, '\\s*\\.\\s*') + // dot can be surrounded by whitespaces | ||
'\\s*\\(\\s*' // opening parenthesis can be surrounded by whitespaces | ||
); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129188
12
252
2
5
3
+ Addedcommander@^2.11.0
+ Addedcommander@2.20.3(transitive)