Skip to content

Commit

Permalink
Add support for missing tasks.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed May 10, 2018
1 parent eb9a2de commit f1ab2b6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-conf",
"version": "1.16.1",
"version": "1.16.2",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/fn/compile-app-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = (projectDir /*, couchUrl */) => {
contact_summary: readJs(projectDir, 'contact-summary.js'),
nools: readJs(projectDir, 'rules.nools.js'),
targets: fs.readJson(`${projectDir}/targets.json`),
tasks_schedules: fs.readJson(`${projectDir}/tasks.json`),
tasks_schedules: readOptionalJson(`${projectDir}/tasks.json`),
};

const app_settings = files.app_settings;
Expand All @@ -48,6 +48,10 @@ module.exports = (projectDir /*, couchUrl */) => {

};

const readOptionalJson = path => {
if(fs.exists(path)) return fs.readJson(path);
};

function applyTransforms(app_settings, inherited) {
doDelete(app_settings, inherited.delete);
doReplace(app_settings, inherited.replace);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"contact_summary": "",
"tasks": {
"rules": "",
"targets": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions test/fn/compile-app-settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('compile-app-settings', () => {
it('should handle nools & contact-summary templating', () =>
test('templating/project'));

it('should handle config with no separate tasks.json file', () =>
test('no-tasks.json/project'));

});

function test(relativeProjectDir) {
Expand Down

0 comments on commit f1ab2b6

Please sign in to comment.