Skip to content

Commit

Permalink
Merge pull request #701 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu committed Sep 28, 2019
2 parents 4aa8bde + 37d7d54 commit 66683a0
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 82 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Actionable task definition files contain the following keys:
- `target`: The relative file path to the target file in the project that robo-config is used in.
- `format` (_optional_): Indicates the format of the target file. E.g. the file extension might be `dat`, but the content `xml`).
Automatically deduced by default. See [smart-fs](https://github.com/blackflux/smart-fs) for supported formats.
- `resolve`: Whether or not to resolve the snippet.
- `strategy`: One of the available merge strategies. These are detailed below.
- `create` (_optional_): When set to `false`, no action is taken if the file does not already exist.
- `pretty` (_optional_): By default files are written in [pretty-mode](https://github.com/blackflux/smart-fs). Can be set to `false` to deactivate. Note that files are only written when the _logical_ content changes.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@
"object-deep-contain": "1.0.19",
"object-scan": "10.0.13",
"object-treeify": "1.1.20",
"smart-fs": "1.9.14"
"smart-fs": "1.10.1"
}
}
4 changes: 3 additions & 1 deletion src/plugin/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const strategies = require('./strategies');
const taskSchema = Joi.object().keys({
target: Joi.string().optional(),
format: Joi.string().allow(null).optional(),
resolve: Joi.boolean().optional(),
strategy: Joi.string().valid(...Object.keys(strategies)).optional(),
create: Joi.boolean().optional(),
pretty: Joi.boolean().optional(),
Expand All @@ -29,6 +30,7 @@ const taskSchema = Joi.object().keys({
tasks: Joi.array().items(Joi.string()).optional()
})
.and('target', 'strategy', 'create', 'snippets', 'format', 'requires', 'purpose')
.with('resolve', 'target')
.and('tasks', 'description')
.xor('target', 'tasks');

Expand All @@ -41,7 +43,7 @@ const loadSnippet = (snippetDir, snippetName, task, snippetVars) => {

const fileName = sfs.guessFile(path.join(snippetDir, snippetName));
assert(fileName !== null, `Invalid Snippet File Name: ${snippetName}`);
const snippet = sfs.smartRead(fileName, { treatAs: task.format });
const snippet = sfs.smartRead(fileName, { treatAs: task.format, resolve: task.resolve || false });

return populateVars(snippet, snippetVars, false);
};
Expand Down
Loading

0 comments on commit 66683a0

Please sign in to comment.