memfs
Advanced tools
Comparing version 0.0.6 to 0.0.7
39
index.js
/// <reference path="typings/tsd.d.ts" /> | ||
var __extends = this.__extends || function (d, b) { | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
__.prototype = b.prototype; | ||
d.prototype = new __(); | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
@@ -66,3 +66,3 @@ /** | ||
return Stats; | ||
})(); | ||
}()); | ||
memfs.Stats = Stats; | ||
@@ -101,3 +101,3 @@ var Node = (function () { | ||
return Node; | ||
})(); | ||
}()); | ||
memfs.Node = Node; | ||
@@ -122,3 +122,3 @@ var File = (function (_super) { | ||
return File; | ||
})(Node); | ||
}(Node)); | ||
memfs.File = File; | ||
@@ -131,6 +131,6 @@ var Directory = (function (_super) { | ||
return Directory; | ||
})(Node); | ||
}(Node)); | ||
memfs.Directory = Directory; | ||
// A single `JSON` file of data mounted to a single mount point. | ||
// We have it so that we can store file contents in a single `.files` map. | ||
// We have it so that we can store file contents in a single JS string dictionary. | ||
var Layer = (function () { | ||
@@ -150,3 +150,3 @@ function Layer(mountpoint, files) { | ||
return Layer; | ||
})(); | ||
}()); | ||
memfs.Layer = Layer; | ||
@@ -261,3 +261,3 @@ // A collection of layers, we have this, so that we override functions with `.attach()` only once. | ||
else { | ||
return f.getData(); // String | ||
// return f.getData(); // String | ||
var Buffer = require('buffer').Buffer; | ||
@@ -373,4 +373,13 @@ return new Buffer(f.getData()); // Buffer | ||
Volume.prototype.writeFileSync = function (filename, data, options) { | ||
var file = this.getFile(filename); | ||
file.setData(data); | ||
try { | ||
var file = this.getFile(filename); | ||
} | ||
catch (e) { | ||
var fullpath = path.resolve(filename); | ||
var layer = this.getLayerContainingPath(fullpath); | ||
if (!layer) | ||
throw Error('Cannot create new file at this path: ' + fullpath); | ||
var file = this.addFile(fullpath, layer); | ||
} | ||
file.setData(data.toString()); | ||
}; | ||
@@ -674,3 +683,3 @@ // fs.writeFile(filename, data[, options], callback) | ||
callback = mode; | ||
mode = 0666; | ||
mode = 438; // 0666 | ||
} | ||
@@ -777,3 +786,3 @@ var self = this; | ||
callback = mode; | ||
mode = 0777; | ||
mode = 511; // 0777 | ||
} | ||
@@ -993,5 +1002,5 @@ var self = this; | ||
return Volume; | ||
})(); | ||
}()); | ||
memfs.Volume = Volume; | ||
})(memfs || (memfs = {})); | ||
module.exports = memfs; |
{ | ||
"name": "memfs", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "In-memory file-system with node.js `fs` API", | ||
"main": "index.js", | ||
"keywords": ["fs", "file", "file system", "mount", "memory", "in-memory", "virtual"], | ||
"repository": { | ||
@@ -10,2 +11,2 @@ "type" : "git", | ||
} | ||
} | ||
} |
# memfs | ||
A `fs` API to work with *virtual in-memory* files. | ||
A [`fs`](https://nodejs.org/api/fs.html) API to work with *virtual in-memory* files. | ||
@@ -31,3 +31,3 @@ ```javascript | ||
// Replace `fs` with the union of thos file systems. | ||
// Replace `fs` with the union of those file systems. | ||
unionfs.replace(fs); | ||
@@ -34,0 +34,0 @@ |
Sorry, the diff of this file is not supported yet
57639
12
1003