Skip to content

Commit 958fdcd

Browse files
committed
Replace web-fs with browserify-fs. Closes GH-3
1 parent 2eab95c commit 958fdcd

File tree

4 files changed

+18
-41
lines changed

4 files changed

+18
-41
lines changed

create-webfs.js

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

demo.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ var through = require('through');
44
var fs = require('fs');
55

66
var browserify_builtins = require('browserify/lib/builtins');
7-
8-
browserify_builtins.fs = 'create-webfs.js'; // TODO: find a better way to replace this module
9-
browserify_builtins['graceful-fs'] = 'create-webfs.js';
7+
browserify_builtins.child_process = 'child_process.js';
8+
browserify_builtins.fs = require.resolve('browserify-fs'); // TODO: what is the api equivalent of cli -r fs:browserify-fs?
9+
browserify_builtins['graceful-fs'] = browserify_builtins.fs;
1010

1111
var b = browserify();
1212

13+
//b.require('browserify-fs', {expose:'fs'});
14+
1315
//b.transform('brfs');
1416

1517
var textReplacements = [

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"npm": "^2.5.0",
1717
"browserify": "^8.1.3",
1818
"wzrd": "^1.2.1",
19-
"web-fs": "^1.5.1",
2019
"brfs": "^1.3.0",
21-
"through": "^2.3.6"
20+
"through": "^2.3.6",
21+
"browserify-fs": "^1.0.0"
2222
},
2323
"license": "MIT"
2424
}

webnpm.js

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,36 +85,18 @@ window.npmCommandRequire = function(path) {
8585
console.log('no such npm command module, update npmCommandRequire:',path);
8686
}
8787

88-
var webfs = require('web-fs');
89-
90-
// https://github.com/mmckegg/web-fs
91-
navigator.webkitPersistentStorage.requestQuota(1024*1024, function(grantedBytes) {
92-
console.log('granted bytes',grantedBytes);
93-
window.webkitRequestFileSystem(PERSISTENT, grantedBytes, function(result) {
94-
console.log('requested filesystem', result);
95-
global.webfs = webfs(result.root);
96-
var fs = global.webfs;
97-
98-
fs.statSync = function(file) {
99-
return {
100-
isFile: function() { return true; },
101-
isFIFO: function() { return false; },
102-
};
103-
};
104-
105-
fs.readdirSync = window.staticReaddirSync;
106-
107-
fs.mkdir('/node_modules', function() {
108-
console.log('created /node_modules');
109-
fs.mkdir('/node_modules/npm', function() {
110-
console.log('created /node_modules/npm');
111-
112-
main(fs);
113-
});
114-
});
115-
});
116-
});
88+
var fs = require('fs');
89+
90+
fs.statSync = function(file) {
91+
return {
92+
isFile: function() { return true; },
93+
isFIFO: function() { return false; },
94+
};
95+
};
96+
97+
fs.readdirSync = window.staticReaddirSync;
11798

99+
main(fs);
118100

119101
function main() {
120102
var browserify = require('browserify');

0 commit comments

Comments
 (0)