@lingui/conf
Advanced tools
Comparing version 2.0.0-0 to 2.0.0-1
76
index.js
@@ -1,1 +0,75 @@ | ||
export * from "./src" | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.replaceRootDir = replaceRootDir; | ||
exports.getConfig = getConfig; | ||
var path = require("path"); | ||
var chalk = require("chalk"); | ||
var pkgConf = require("pkg-conf"); | ||
var _require = require("jest-validate"), | ||
validate = _require.validate; | ||
var _require2 = require("jest-regex-util"), | ||
replacePathSepForRegex = _require2.replacePathSepForRegex; | ||
var NODE_MODULES = replacePathSepForRegex(path.sep + "node_modules" + path.sep); | ||
function replaceRootDir(conf, rootDir) { | ||
var replace = function replace(s) { | ||
return s.replace("<rootDir>", rootDir); | ||
}; | ||
["srcPathDirs", "srcPathIgnorePatterns", "localeDir"].forEach(function (key) { | ||
var value = conf[key]; | ||
if (!value) {} else if (typeof value === "string") { | ||
conf[key] = replace(value); | ||
} else if (value.length) { | ||
conf[key] = value.map(replace); | ||
} | ||
}); | ||
conf.rootDir = rootDir; | ||
return conf; | ||
} | ||
var defaults = { | ||
localeDir: "./locale", | ||
sourceLocale: "", | ||
fallbackLocale: "", | ||
srcPathDirs: ["<rootDir>"], | ||
srcPathIgnorePatterns: [NODE_MODULES], | ||
format: "lingui", | ||
rootDir: "." | ||
}; | ||
var deprecatedConfig = { | ||
fallbackLanguage: function fallbackLanguage(config) { | ||
return " Option ".concat(chalk.bold("fallbackLanguage"), " was replaced by ").concat(chalk.bold("fallbackLocale"), "\n \n lingui-cli now treats your current configuration as:\n {\n ").concat(chalk.bold('"fallbackLocale"'), ": ").concat(chalk.bold("\"".concat(config.fallbackLanguage, "\"")), "\n }\n \n Please update your configuration.\n "); | ||
} | ||
}; | ||
var configValidation = { | ||
exampleConfig: defaults, | ||
deprecatedConfig: deprecatedConfig, | ||
comment: "See https://l.lingui.io/ref-lingui-conf for a list of valid options" | ||
}; | ||
function getConfig() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
cwd = _ref.cwd; | ||
var raw = pkgConf.sync("lingui", { | ||
defaults: defaults, | ||
skipOnFalse: true, | ||
cwd: cwd || process.cwd() | ||
}); | ||
validate(raw, configValidation); // Use deprecated fallbackLanguage, if defined | ||
raw.fallbackLocale = raw.fallbackLocale || raw.fallbackLanguage || ""; | ||
var rootDir = path.dirname(pkgConf.filepath(raw)); | ||
return replaceRootDir(raw, rootDir); | ||
} |
{ | ||
"name": "@lingui/conf", | ||
"version": "2.0.0-0", | ||
"version": "2.0.0-1", | ||
"description": "Get lingui configuration from package.json", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5362
4
61
0