Skip to content

Commit

Permalink
fix(attach.js): mkdir resourcesPath if not exists
Browse files Browse the repository at this point in the history
fix(attach.js): test mkdir resourcesPath
  • Loading branch information
ericfong authored and NicolasRitouet committed Jan 30, 2015
1 parent 077c2b9 commit 55cf4b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/attach.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var util = require('util');
var fs = require('fs');
var path = require('path');
var debug = require('debug')('server');
var _ = require('underscore');

Expand Down Expand Up @@ -126,6 +127,13 @@ function attach(httpServer, options) {


var serverpath = server.options.server_dir || fs.realpathSync('./');

// mkdir resourcesPath if not exists
var resourcesPath = path.join(serverpath, 'resources');
// use sync functions, as only run once when server start-up
if (!fs.existsSync(resourcesPath)) {
fs.mkdirSync(resourcesPath);
}

server.route = function route(req, res) {
config.loadConfig(serverpath, server, function(err, resourcesInstances) {
Expand Down
2 changes: 1 addition & 1 deletion test/attach.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('attach', function() {
beforeEach(function() {
sh.cd(basepath);
sh.rm('-rf', 'resources');
sh.mkdir('resources');
//sh.mkdir('resources');

PORT = genPort();
opts = {
Expand Down

0 comments on commit 55cf4b3

Please sign in to comment.