diff --git a/lib/daemon.js b/lib/daemon.js index e4f90b8..0530785 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -537,18 +537,16 @@ var daemon = function (config) { dir = this.directory(dir); // If the output directory does not exist, create it. - fs.exists(dir, function (exists) { - if (!exists) { - fs.mkdirSync(dir); - } - // Write the configuration file - fs.writeFile(path.resolve(dir, me.id + '.xml'), me._xml, function () { - // Write the exe file - winsw.createExe(me.id, dir, function () { - me.execute('"' + path.resolve(dir, me._exe) + '" install', function () { - sleep(2); - me.emit('install'); - }); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + // Write the configuration file + fs.writeFile(path.resolve(dir, me.id + '.xml'), me._xml, function () { + // Write the exe file + winsw.createExe(me.id, dir, function () { + me.execute('"' + path.resolve(dir, me._exe) + '" install', function () { + sleep(2); + me.emit('install'); }); }); });