Skip to content

Commit

Permalink
WARN if form dirs are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jul 17, 2017
1 parent 805c426 commit bd362d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-configurer-beta",
"version": "1.0.64",
"version": "1.0.65",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/convert-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const exec = require('../lib/exec-promise');
const fs = require('../lib/sync-fs');
const info = require('../lib/log').info;
const trace = require('../lib/log').trace;
const warn = require('../lib/log').warn;

const XLS2XFORM = 'xls2xform-medic';

Expand All @@ -11,6 +12,11 @@ module.exports = (project, subDirectory, options) => {

const formsDir = `${project}/forms/${subDirectory}`;

if(!fs.exists(formsDir)) {
warn(`Forms dir not found: ${formsDir}`);
return Promise.resolve();
}

return fs.readdir(formsDir)
.filter(name => name.endsWith('.xlsx'))
.filter(name => !name.startsWith('~$')) // ignore Excel "owner files"
Expand Down
6 changes: 6 additions & 0 deletions src/lib/upload-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = (project, couchUrl, subDirectory, options) => {
if(!options) options = {};

const formsDir = `${project}/forms/${subDirectory}`;

if(!fs.exists(formsDir)) {
warn(`Forms dir not found: ${formsDir}`);
return Promise.resolve();
}

return Promise.all(fs.readdir(formsDir)
.filter(name => name.endsWith('.xml'))
.filter(name => !options.forms || options.forms.includes(fs.withoutExtension(name)))
Expand Down

0 comments on commit bd362d5

Please sign in to comment.