Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync read file & require of json files
- Loading branch information
1 parent
a7d7393
commit 7ec9c31
Showing
6 changed files
with
129 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var fsPath = window.xpcModule.require('path'); | ||
|
||
exports.readFileSync = function readFileSync(name) { | ||
var xhr = new XMLHttpRequest(); | ||
var path = fsPath.resolve(name); | ||
|
||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', 'file://' + path, false); | ||
|
||
xhr.send(null); | ||
return xhr.responseText; | ||
}; | ||
|
||
exports.writeFileSync = function writeFileSync() { | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"json": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe('modules/fs', function() { | ||
var fs = window.xpcModule.require('fs'); | ||
|
||
describe('read', function() { | ||
var fileName = __dirname + '/../fixtures/file.js'; | ||
var expected = 'local file'; | ||
|
||
describe('readFileSync', function() { | ||
it('should be able to read files', function() { | ||
var result = fs.readFileSync(fileName); | ||
expect(result).to.contain('local file'); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters