Skip to content

Commit 963f1fa

Browse files
committed
create subdirs for new config files
1 parent 381a074 commit 963f1fa

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

files/fixtures/non-existing-config.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var fs = require('fs');
1+
var fs = require('fs-extra');
22
var esprima = require('esprima');
33
var _ = require('lodash');
44
var util = require('util');
@@ -93,7 +93,7 @@ exports.ConfigFile = function(filePath) {
9393
contents = that.contents.substring(0, that.range[0]) + that.buildConfig() + that.contents.substring(that.range[1]);
9494
}
9595

96-
fs.writeFile(filePath, contents, callback);
96+
fs.outputFile(filePath, contents, callback);
9797
};
9898

9999
/**

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"dependencies": {
3232
"esprima": "~1.0.4",
3333
"lodash": "~2.0.0",
34-
"stringify-object": "~0.1.7"
34+
"stringify-object": "~0.1.7",
35+
"fs-extra": "~0.6.4"
3536
}
3637
}

test/config-file-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ describe("ConfigFile", function() {
208208
done();
209209
});
210210
});
211+
212+
213+
it("writes the file and creates directories", function(done) {
214+
var nonExistingFile = tmpPath('in/directory/non-existing-config.js');
215+
var configFile = new ConfigFile(nonExistingFile);
216+
217+
configFile.createIfNotExists();
218+
219+
configFile.write(function (err) {
220+
expect(err).to.not.exist;
221+
done();
222+
});
223+
});
211224
});
212225
});
213226
});

0 commit comments

Comments
 (0)