Skip to content

Commit

Permalink
Merge pull request #973 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu authored Oct 8, 2020
2 parents a7b8a17 + d5a2afa commit adab35a
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions .idea/jsLinters/eslint.xml

This file was deleted.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ Useful for loading improved [serverless](https://serverless.com/) configuration.

$ npm install --save yaml-boost

## Api

### resolve(refPath, content, vars)

Resolve content with variables at given refPath.

### load(filePath, vars = {})

Load filePath with given variables.

### dump

As provided by `js-yaml` through `safeDump`

## Usage

<!-- eslint-disable import/no-unresolved, import/no-extraneous-dependencies -->
Expand Down Expand Up @@ -84,7 +98,7 @@ Once can reference files relative to the current file by using `^` as a prefix l

```yaml
${file(^/subfolder/of/current/file.yml)}
```
```

##### Deep Merge

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
"@babel/core": "7.11.6",
"@babel/register": "7.11.5",
"@blackflux/eslint-plugin-rules": "1.3.40",
"@blackflux/robo-config-plugin": "3.10.3",
"@blackflux/robo-config-plugin": "3.10.7",
"babel-eslint": "10.1.0",
"chai": "4.2.0",
"coveralls": "3.1.0",
"eslint": "7.9.0",
"eslint": "7.10.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-json": "2.1.2",
"eslint-plugin-markdown": "1.0.2",
"eslint-plugin-mocha": "8.0.0",
"js-gardener": "2.0.175",
"js-gardener": "2.0.176",
"nyc": "15.1.0",
"semantic-release": "17.1.1",
"babel-preset-latest-node": "4.1.0"
"semantic-release": "17.1.2",
"babel-preset-latest-node": "5.0.0"
},
"keywords": [
"yaml",
Expand Down
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ const loadRecursive = (dir, relDir, data, vars) => {
return result;
};

module.exports.load = (filePath, vars = {}) => loadRecursive(
path.dirname(filePath),
path.dirname(filePath),
const resolve = (refPath, content, vars) => {
const dirname = path.dirname(refPath);
return loadRecursive(dirname, dirname, content, vars);
};
module.exports.resolve = resolve;

module.exports.load = (filePath, vars = {}) => resolve(
filePath,
yaml.safeLoad(fs.readFileSync(filePath, 'utf8')),
vars
);
Expand Down
115 changes: 57 additions & 58 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,23 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037"
integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==

"@babel/plugin-proposal-nullish-coalescing-operator@^7.8.3":
"@babel/plugin-proposal-nullish-coalescing-operator@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.10.4.tgz#02a7e961fc32e6d5b2db0649e01bf80ddee7e04a"
integrity sha512-wq5n1M3ZUlHl9sqT2ok1T2/MTt6AXE0e1Lz4WzWBr95LsAZ5qDXe4KnFuauYyEyLiohvXFMdbsOTMyLZs91Zlw==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0"

"@babel/plugin-proposal-optional-catch-binding@^7.8.3":
"@babel/plugin-proposal-optional-catch-binding@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.10.4.tgz#31c938309d24a78a49d68fdabffaa863758554dd"
integrity sha512-LflT6nPh+GK2MnFiKDyLiqSqVHkQnVf7hdoAvyTnnKj9xB3docGRsdPuxp6qqqW19ifK3xgc9U5/FwrSaCNX5g==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-optional-catch-binding" "^7.8.0"

"@babel/plugin-proposal-optional-chaining@^7.9.0":
"@babel/plugin-proposal-optional-chaining@^7.10.4":
version "7.11.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.11.0.tgz#de5866d0646f6afdaab8a566382fe3a221755076"
integrity sha512-v9fZIu3Y8562RRwhm1BbMRxtqZNFmFA2EG+pT2diuU8PT3H6T/KXoZ54KgYisfOFZHV6PfvAiBIZ9Rcz+/JCxA==
Expand All @@ -219,29 +219,29 @@
"@babel/helper-skip-transparent-expression-wrappers" "^7.11.0"
"@babel/plugin-syntax-optional-chaining" "^7.8.0"

"@babel/plugin-proposal-unicode-property-regex@^7.8.8":
"@babel/plugin-proposal-unicode-property-regex@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.10.4.tgz#4483cda53041ce3413b7fe2f00022665ddfaa75d"
integrity sha512-H+3fOgPnEXFL9zGYtKQe4IDOPKYlZdF1kqFDQRRb8PK4B8af1vAGK04tF5iQAAsui+mHNBQSAtd2/ndEDe9wuA==
dependencies:
"@babel/helper-create-regexp-features-plugin" "^7.10.4"
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-syntax-json-strings@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a"
integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.0":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9"
integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-optional-catch-binding@^7.8.0", "@babel/plugin-syntax-optional-catch-binding@^7.8.3":
"@babel/plugin-syntax-numeric-separator@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97"
integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-syntax-optional-catch-binding@^7.8.0":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1"
integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==
Expand All @@ -255,7 +255,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-transform-modules-commonjs@^7.9.0":
"@babel/plugin-transform-modules-commonjs@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.10.4.tgz#66667c3eeda1ebf7896d41f1f16b17105a2fbca0"
integrity sha512-Xj7Uq5o80HDLlW64rVfDBhao6OX89HKUmb+9vWYaLXBZOma4gA6tw4Ni1O5qVDoZWUV0fxMYA0aYzOawz0l+1w==
Expand Down Expand Up @@ -316,10 +316,10 @@
dependencies:
smart-fs "1.11.21"

"@blackflux/[email protected].3":
version "3.10.3"
resolved "https://registry.yarnpkg.com/@blackflux/robo-config-plugin/-/robo-config-plugin-3.10.3.tgz#512e4d3ba21a01fb1bca67a0b6f027d810b65a88"
integrity sha512-KSSXK/1ypJN2CVkR8c0sVX8iBhKE5U374KyVivNxFAnocgf8eiYzbJLqVeZmGGVrRAExCp65uQTY/GNkkaVDNQ==
"@blackflux/[email protected].7":
version "3.10.7"
resolved "https://registry.yarnpkg.com/@blackflux/robo-config-plugin/-/robo-config-plugin-3.10.7.tgz#a54da9838ee3d98c1b8ac210de9760a423327e0a"
integrity sha512-8yfJ6I/eTon65SDmUSDX6EuoQQvwjEbTafuas839sOYfkHIkg5PBfqxVzWghSW5n1WzOnnwtvOhqT8YI8SA6cw==

"@eslint/eslintrc@^0.1.3":
version "0.1.3"
Expand Down Expand Up @@ -1020,18 +1020,17 @@ babel-plugin-dynamic-import-node@^2.3.3:
dependencies:
object.assign "^4.1.0"

babel-preset-latest-node@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/babel-preset-latest-node/-/babel-preset-latest-node-4.1.0.tgz#b5696cf19b0106b515890a427274f67ac009e8c8"
integrity sha512-LOdNzg2qtx+rHE0++hPjhIEJy8X3jkuhfV0oe8peVeXUjTY4jUEo18263WKNSqyn/Vg6ym9LK0rCywc51e/okQ==
babel-preset-latest-node@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/babel-preset-latest-node/-/babel-preset-latest-node-5.0.0.tgz#1c776799455889585ce7a731184b4964fc54e1df"
integrity sha512-FxabAzGKRkD6oFB10RrYoyS2Nuk/NNU+aJPVTOkX164EZvOF8r/5P3RaM0ed/1Iv7uugoPpSVW024ANEaHisCg==
dependencies:
"@babel/plugin-proposal-nullish-coalescing-operator" "^7.8.3"
"@babel/plugin-proposal-optional-catch-binding" "^7.8.3"
"@babel/plugin-proposal-optional-chaining" "^7.9.0"
"@babel/plugin-proposal-unicode-property-regex" "^7.8.8"
"@babel/plugin-syntax-json-strings" "^7.8.3"
"@babel/plugin-syntax-optional-catch-binding" "^7.8.3"
"@babel/plugin-transform-modules-commonjs" "^7.9.0"
"@babel/plugin-proposal-nullish-coalescing-operator" "^7.10.4"
"@babel/plugin-proposal-optional-catch-binding" "^7.10.4"
"@babel/plugin-proposal-optional-chaining" "^7.10.4"
"@babel/plugin-proposal-unicode-property-regex" "^7.10.4"
"@babel/plugin-syntax-numeric-separator" "^7.10.4"
"@babel/plugin-transform-modules-commonjs" "^7.10.4"

babel-runtime@^6.6.1:
version "6.26.0"
Expand Down Expand Up @@ -2275,7 +2274,7 @@ [email protected]:
object.assign "^4.1.0"
object.entries "^1.1.2"

eslint-import-resolver-node@^0.3.3:
eslint-import-resolver-node@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717"
integrity sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==
Expand All @@ -2291,17 +2290,17 @@ eslint-module-utils@^2.6.0:
debug "^2.6.9"
pkg-dir "^2.0.0"

[email protected].0:
version "2.22.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz#92f7736fe1fde3e2de77623c838dd992ff5ffb7e"
integrity sha512-66Fpf1Ln6aIS5Gr/55ts19eUuoDhAbZgnr6UxK5hbDx6l/QgQgx61AePq+BV4PP2uXQFClgMVzep5zZ94qqsxg==
[email protected].1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz#0896c7e6a0cf44109a2d97b95903c2bb689d7702"
integrity sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==
dependencies:
array-includes "^3.1.1"
array.prototype.flat "^1.2.3"
contains-path "^0.1.0"
debug "^2.6.9"
doctrine "1.5.0"
eslint-import-resolver-node "^0.3.3"
eslint-import-resolver-node "^0.3.4"
eslint-module-utils "^2.6.0"
has "^1.0.3"
minimatch "^3.0.4"
Expand Down Expand Up @@ -2335,12 +2334,12 @@ [email protected]:
eslint-utils "^2.1.0"
ramda "^0.27.1"

eslint-scope@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.0.tgz#d0f971dfe59c69e0cada684b23d49dbf82600ce5"
integrity sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==
eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==
dependencies:
esrecurse "^4.1.0"
esrecurse "^4.3.0"
estraverse "^4.1.1"

eslint-utils@^2.1.0:
Expand All @@ -2355,10 +2354,10 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==

eslint@7.9.0:
version "7.9.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.9.0.tgz#522aeccc5c3a19017cf0cb46ebfd660a79acf337"
integrity sha512-V6QyhX21+uXp4T+3nrNfI3hQNBDa/P8ga7LoQOenwrlEFXrEnUEE+ok1dMtaS3b6rmLXhT1TkTIsG75HMLbknA==
eslint@7.10.0:
version "7.10.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.10.0.tgz#494edb3e4750fb791133ca379e786a8f648c72b9"
integrity sha512-BDVffmqWl7JJXqCjAK6lWtcQThZB/aP1HXSH1JKwGwv0LQEdvpR7qzNrUT487RM39B5goWuboFad5ovMBmD8yA==
dependencies:
"@babel/code-frame" "^7.0.0"
"@eslint/eslintrc" "^0.1.3"
Expand All @@ -2368,7 +2367,7 @@ [email protected]:
debug "^4.0.1"
doctrine "^3.0.0"
enquirer "^2.3.5"
eslint-scope "^5.1.0"
eslint-scope "^5.1.1"
eslint-utils "^2.1.0"
eslint-visitor-keys "^1.3.0"
espree "^7.3.0"
Expand Down Expand Up @@ -2419,7 +2418,7 @@ esquery@^1.2.0:
dependencies:
estraverse "^5.1.0"

esrecurse@^4.1.0:
esrecurse@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==
Expand Down Expand Up @@ -3944,10 +3943,10 @@ [email protected]:
dependencies:
"@hapi/joi" "17.1.1"

[email protected].175:
version "2.0.175"
resolved "https://registry.yarnpkg.com/js-gardener/-/js-gardener-2.0.175.tgz#fc90ffaa13e4cfd04ee471a98f61e7b191bb1458"
integrity sha512-W3bRxleK7pEN2sPm/N4SEj7M33QwFjXOC8G5CGDB8HqEyxwYSw/gUm2qUzoxRUZGdYYObv2wScvPzfyqgz1N7g==
[email protected].176:
version "2.0.176"
resolved "https://registry.yarnpkg.com/js-gardener/-/js-gardener-2.0.176.tgz#a172e51110fa81dabbafed83acd4c7edc8103783"
integrity sha512-61yKYbTwkXIXxKPktPaWgos4wIthp/T7wnFHY99lnrTny5C+/H0X1WzR6Di6UkQHZFtHe+5sjBWjKJZ9fuc6sQ==
dependencies:
chalk "4.1.0"
fancy-log "1.3.3"
Expand All @@ -3958,7 +3957,7 @@ [email protected]:
lodash.get "4.4.2"
mocha "8.1.3"
npm-check "5.9.2"
robo-config "3.8.14"
robo-config "3.9.0"

js-tokens@^3.0.0:
version "3.0.2"
Expand Down Expand Up @@ -6513,10 +6512,10 @@ rimraf@^3.0.0:
dependencies:
glob "^7.1.3"

robo-config@3.8.14:
version "3.8.14"
resolved "https://registry.yarnpkg.com/robo-config/-/robo-config-3.8.14.tgz#ff5d5f20da3860c410ef7ceeb2e307d1bea51902"
integrity sha512-6HGQiZzGUXL/pogaBGmxvxNCYoP0EMc4X0uDUnSDWs64zYDDFEj+F+iI1pKBqmQ71r2SRDwTuxCAUxZafU6pEA==
robo-config@3.9.0:
version "3.9.0"
resolved "https://registry.yarnpkg.com/robo-config/-/robo-config-3.9.0.tgz#647bca313a925dcac7544bf9029c7f3e2596b6a5"
integrity sha512-66jcHYAODIJM+fMBLPobRfuw9ZdTGBvj16g5Bt4EHOQc/bCOqY6Z9RAbGyXrEvdgebxNYJDF6pfPBL2qpwoytg==
dependencies:
app-root-path "3.0.0"
deepmerge "4.2.2"
Expand Down Expand Up @@ -6580,10 +6579,10 @@ sax@^1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==

[email protected].1:
version "17.1.1"
resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-17.1.1.tgz#d9775968e841b2b7c5020559e4481aea8520ca75"
integrity sha512-9H+207eynBJElrQBHySZm+sIEoJeUhPA2zU4cdlY1QSInd2lnE8GRD2ALry9EassE22c9WW+aCREwBhro5AIIg==
[email protected].2:
version "17.1.2"
resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-17.1.2.tgz#7d77555185722012b34e3ca74e4d13f813daf3cd"
integrity sha512-szYBXm10QjQO5Tb1S2PSkvOBW3MajWJat5EWtx+MzaVT/jquuxf9o+Zn8FC1j157xvJ5p9r1d/MZGslgs7oQQg==
dependencies:
"@semantic-release/commit-analyzer" "^8.0.0"
"@semantic-release/error" "^2.2.0"
Expand Down

0 comments on commit adab35a

Please sign in to comment.