Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Fix crash when calling build and slice directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dianashk committed Mar 31, 2015
1 parent 39e7caa commit e7499fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ var exec = require('child_process').exec;
*
* @param {string} inputFile
* @param {string} outputDir
* @param {object} [options] commander will pass this argument, not used
* @param {function} [callback] optional
*/
module.exports = function build(inputFile, outputDir, callback) {
module.exports = function build(inputFile, outputDir, options, callback) {
fs.ensureDir(outputDir);

var cmd = util.format('./node_modules/.bin/fences-builder --inputFile=%s --outputDir=%s', inputFile, outputDir);
Expand All @@ -26,7 +27,7 @@ module.exports = function build(inputFile, outputDir, callback) {
console.error(colors.red('[exec error]'), error);
}

if (callback) {
if (callback && typeof callback === 'function') {
callback();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function prep(pbfFile, outputFile, options, callback) {
convert.bind(null, filteredOsmFile, outputFile)
],
function () {
if (callback) {
if (callback && typeof callback === 'function') {
callback();
}
else {
Expand Down
11 changes: 8 additions & 3 deletions src/slice.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// this function has too many parameters, but the are coming from commander and cannot be refactored
/* jshint ignore:start */

var util = require('util');
var fs = require('fs');
var fs_extra = require('fs-extra');
Expand All @@ -10,9 +13,10 @@ var exec = require('child_process').exec;
* @param {string} regionFile
* @param {string} inputDir
* @param {string} outputDir
* @param {object} [options] commander will pass this argument, not used
* @param {function} [callback] optional
*/
module.exports = function slice(regionFile, inputDir, outputDir, callback) {
module.exports = function slice(regionFile, inputDir, outputDir, options, callback) {
if (!fs.existsSync(regionFile) || !fs.existsSync(inputDir)) {
console.error(colors.red('[Error]:'), 'Region file or inputDir do not exist');
process.exit(1);
Expand All @@ -35,11 +39,12 @@ module.exports = function slice(regionFile, inputDir, outputDir, callback) {
console.error(colors.red('[exec error]'), error);
}

if (callback) {
if (callback && typeof callback === 'function') {
callback();
}
else {
console.log(colors.green('All done!'));
}
});
};
};
/* jshint ignore:end */

0 comments on commit e7499fe

Please sign in to comment.