@hh.ru/babel-plugin-static-value-extractor
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -127,4 +127,5 @@ 'use strict'; | ||
if (content !== previousContent) { | ||
_fs2.default.mkdirSync(saveFilePath, { recursive: true }); | ||
_fs2.default.writeFileSync(saveFilePath + '/' + opts.saveFileName + '.' + opts.saveFileExt, content); | ||
} | ||
}; |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var JS_EXTENSIONS = ['', 'js', 'jsx']; | ||
var getConcatenatedStaticProps = function getConcatenatedStaticProps(staticProps, nodeStaticProps) { | ||
@@ -32,2 +34,15 @@ return staticProps.concat(nodeStaticProps.reduce(function (arr, _ref) { | ||
var isJsFile = function isJsFile(path) { | ||
return JS_EXTENSIONS.includes(_path2.default.parse(path).ext); | ||
}; | ||
var replacePath = function replacePath(path) { | ||
var pathsToReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return Object.keys(pathsToReplace).filter(function (checkPath) { | ||
return path.startsWith(checkPath); | ||
}).reduce(function (result, checkPath) { | ||
return _path2.default.normalize(result.replace(checkPath, pathsToReplace[checkPath])); | ||
}, path); | ||
}; | ||
exports.default = function (cb) { | ||
@@ -38,3 +53,4 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var currentFileDir = _path2.default.parse(opts.filename).dir; | ||
var staticPropName = opts.staticPropName; | ||
var staticPropName = opts.staticPropName, | ||
pathsToReplace = opts.pathsToReplace; | ||
@@ -106,4 +122,4 @@ var importDeclarationPaths = []; | ||
if (node && node.source && !_path2.default.isAbsolute(node.source.value) && node.source.value[0] === '.') { | ||
processImports(node.source.value); | ||
if (node && node.source && isJsFile(node.source.value)) { | ||
processImports(replacePath(node.source.value, pathsToReplace)); | ||
} | ||
@@ -110,0 +126,0 @@ } |
{ | ||
"name": "@hh.ru/babel-plugin-static-value-extractor", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"main": "lib/index.js", | ||
@@ -9,4 +9,8 @@ "devDependencies": { | ||
"babel-preset-stage-0": "^6.24.1", | ||
"del": "^3.0.0", | ||
"mocha": "5.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"repository": { | ||
@@ -29,5 +33,4 @@ "type": "git", | ||
"babel-core": "^6.26.3", | ||
"del": "^3.0.0", | ||
"glob-all": "^3.1.0" | ||
} | ||
} |
@@ -13,7 +13,8 @@ # babel-plugin-static-value-extractor | ||
], { | ||
staticPropName: - имя свойства | ||
saveFileName: - имя файла | ||
saveFilePath: - путь, куда сохранять значения свойств | ||
saveFileExt: - расширение файла, | ||
template: Функция которая возвращает шаблон контента(string), в качестве аргумента передается объект с ключами названий Файлов и значением массивов извлеченных значений, если не передать контентом сохраненного файла будет JSON представление.', | ||
staticPropName: — имя свойства | ||
saveFileName: — имя файла | ||
saveFilePath: — путь, куда сохранять значения свойств | ||
saveFileExt: — расширение файла, | ||
pathsToReplace: — webpackAliases | ||
template: — функция которая возвращает шаблон контента(string), в качестве аргумента передается объект с ключами названий Файлов и значением массивов извлеченных значений, если не передать контентом сохраненного файла будет JSON представление.', | ||
}); | ||
@@ -20,0 +21,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
2
51
3
46151
5
16
193
1
- Removeddel@^3.0.0
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removeddel@3.0.0(transitive)
- Removedglobby@6.1.0(transitive)
- Removedis-path-cwd@1.0.0(transitive)
- Removedis-path-in-cwd@1.0.1(transitive)
- Removedis-path-inside@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedp-map@1.2.0(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpify@2.3.03.0.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedrimraf@2.7.1(transitive)