YUKI Hiroshi
null+****@clear*****
Thu Sep 25 17:34:22 JST 2014
YUKI Hiroshi 2014-09-25 17:34:22 +0900 (Thu, 25 Sep 2014) New Revision: 3781465e42893708763cb7c5e980f55c8b44ecf0 https://github.com/droonga/droonga-http-server/commit/3781465e42893708763cb7c5e980f55c8b44ecf0 Message: Make the base directory before write check Modified files: bin/droonga-http-server-configure package.json Modified: bin/droonga-http-server-configure (+15 -4) =================================================================== --- bin/droonga-http-server-configure 2014-09-25 17:19:41 +0900 (ab951e7) +++ bin/droonga-http-server-configure 2014-09-25 17:34:22 +0900 (46a54a6) @@ -3,6 +3,7 @@ var exec = require('child_process').exec, fs = require('fs'), + mkdirp = require('mkdirp'), path = require('path'), promptly = require('promptly'), Q = require('q'), @@ -67,19 +68,29 @@ function checkInstalledAsService() { } function ensureHaveWritePermission() { + function onFailed() { + console.log('You have no permission to write files under ' + + '<' + baseDir + '>.') + console.log('Try again with right permission.') + process.exit(false) + } return Q.Promise(function(resolve, reject, notify) { + mkdirp(baseDir, { mode: '755' }, function(error) { + if (error) { + onFailed(); + return reject(error); + } + testFile = baseDir + '/' + Date.now() + '.test'; touch(testFile, {}, function(error) { if (error || !fs.existsSync(testFile)) { - console.log('You have no permission to write files under ' + - '<' + baseDir + '>.') - console.log('Try again with right permission.') - process.exit(false) + onFailed(); return reject(error); } fs.unlinkSync(testFile); resolve(); }); + }); }); } Modified: package.json (+1 -0) =================================================================== --- package.json 2014-09-25 17:19:41 +0900 (38aa406) +++ package.json 2014-09-25 17:34:22 +0900 (2e4d3a2) @@ -26,6 +26,7 @@ "express-droonga": ">=1.0.5", "express-session": "*", "js-yaml": "*", + "mkdirp": "*", "morgan": "*", "promptly": "*", "ps-node": "*", -------------- next part -------------- HTML����������������������������... Download