Skip to content

Commit

Permalink
fix: Switch all requires from fs to graceful-fs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Erik Støwer committed Jan 14, 2016
1 parent 81a388a commit 1e21aaa
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var path = require('path')
var optimist = require('optimist')
var fs = require('fs')
var fs = require('graceful-fs')

var Server = require('./server')
var helper = require('./helper')
Expand Down
2 changes: 1 addition & 1 deletion lib/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var completion = function () {
}

// just print out the karma-completion.sh
var fs = require('fs')
var fs = require('graceful-fs')
var path = require('path')

fs.readFile(path.resolve(__dirname, '../scripts/karma-completion.sh'), 'utf8', function (err, data) {
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('graceful-fs')

var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString())

Expand Down
2 changes: 1 addition & 1 deletion lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var from = require('core-js/library/fn/array/from')
var Promise = require('bluebird')
var mm = require('minimatch')
var Glob = require('glob').Glob
var fs = Promise.promisifyAll(require('fs'))
var fs = Promise.promisifyAll(require('graceful-fs'))
var pathLib = require('path')

var File = require('./file')
Expand Down
2 changes: 1 addition & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('graceful-fs')
var path = require('path')
var _ = require('lodash')
var useragent = require('useragent')
Expand Down
2 changes: 1 addition & 1 deletion lib/init/formatters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('graceful-fs')
var util = require('util')

var JS_TEMPLATE_PATH = __dirname + '/../../config.tpl.js'
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('graceful-fs')
var path = require('path')

var helper = require('./helper')
Expand Down
2 changes: 1 addition & 1 deletion lib/temp_dir.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var path = require('path')
var fs = require('fs')
var fs = require('graceful-fs')
var os = require('os')
var rimraf = require('rimraf')
var log = require('./logger').create('temp-dir')
Expand Down
2 changes: 1 addition & 1 deletion lib/web-server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('graceful-fs')
var http = require('http')
var https = require('https')
var path = require('path')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
"load-grunt-tasks": "^3.1.0",
"mkdirp": "^0.5.0",
"mocha": "^2.2.5",
"mock-fs": "^3.6.0",
"mocks": "^0.0.15",
"phantomjs": "^1.9.19",
"proxyquire": "^1.5.0",
Expand Down
24 changes: 14 additions & 10 deletions test/unit/file-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ var MG = {
}
}
var mockFs = mocks.fs.create({
some: {'0.js': mocks.fs.file('2012-04-04'),
some: {
'0.js': mocks.fs.file('2012-04-04'),
'a.js': mocks.fs.file('2012-04-04'),
'b.js': mocks.fs.file('2012-05-05'),
'd.js': mocks.fs.file('2012-05-05')},
folder: {'x.js': mocks.fs.file(0)},
'd.js': mocks.fs.file('2012-05-05')
},
folder: {
'x.js': mocks.fs.file(0)
},
'a.txt': mocks.fs.file(0),
'b.txt': mocks.fs.file(0),
'c.txt': mocks.fs.file(0),
Expand Down Expand Up @@ -77,7 +81,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})
})

Expand Down Expand Up @@ -207,7 +211,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})

list = new List(patterns('/some/*.js', '*.txt'), [], emitter, preprocess)
Expand Down Expand Up @@ -244,7 +248,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})

list = new List(patterns('/some/*.js', '*.txt'), [], emitter, preprocess, 100)
Expand Down Expand Up @@ -414,7 +418,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})

list = new List(patterns('/some/*.js', '*.txt'), ['/secret/*.txt'], emitter, preprocess)
Expand Down Expand Up @@ -527,7 +531,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})

mockFs._touchFile('/some/a.js', '2012-04-04')
Expand Down Expand Up @@ -620,7 +624,7 @@ describe('FileList', () => {
helper: helper,
glob: glob,
path: pathLib.posix || pathLib/* for node 0.10 */,
fs: mockFs
'graceful-fs': mockFs
})

modified = sinon.stub()
Expand Down Expand Up @@ -687,7 +691,7 @@ describe('FileList', () => {
List = proxyquire('../../lib/file-list', {
helper: helper,
glob: glob,
fs: mockFs,
'graceful-fs': mockFs,
path: pathLib.posix || pathLib/* for node 0.10 */,
bluebird: Promise
})
Expand Down
3 changes: 2 additions & 1 deletion test/unit/helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ describe('helper', () => {
})

// load file under test
var m = loadFile(__dirname + '/../../lib/helper.js', {fs: fs, lodash: require('lodash')})
var m = loadFile(__dirname + '/../../lib/helper.js', {'graceful-fs': fs, lodash: require('lodash')})

var mkdirIfNotExists = m.exports.mkdirIfNotExists

it('should not do anything, if dir already exists', done => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/web-server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('web-server', () => {
var _mocks = {}
var _globals = {__dirname: '/karma/lib'}

_mocks.fs = mocks.fs.create({
_mocks['graceful-fs'] = mocks.fs.create({
karma: {
static: {
'client.html': mocks.fs.file(0, 'CLIENT HTML')
Expand Down

0 comments on commit 1e21aaa

Please sign in to comment.