Skip to content

Commit

Permalink
fix(fs): Use graceful-fs instead of fs directly (#221)
Browse files Browse the repository at this point in the history
Prevent `'EMFILE'` errors amongst others by using graceful-fs as a drop-in replacement for file system IO.
  • Loading branch information
nicojs authored and simondel committed Jan 26, 2017
1 parent 397477c commit 4c1bf41
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"escodegen": "^1.8.0",
"esprima": "^2.7.0",
"glob": "^7.0.3",
"graceful-fs": "^4.1.11",
"istanbul": "^0.4.5",
"lodash": "^3.10.1",
"log4js": "^0.6.33",
Expand All @@ -62,6 +63,7 @@
"@types/esprima": "^2.1.31",
"@types/estree": "0.0.32",
"@types/glob": "^5.0.29",
"@types/graceful-fs": "^2.0.29",
"@types/istanbul": "^0.4.29",
"@types/karma": "^0.13.32",
"@types/lodash": "^4.14.34",
Expand Down
2 changes: 1 addition & 1 deletion src/PluginLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
import * as fs from 'graceful-fs';
import * as path from 'path';
import * as log4js from 'log4js';
import * as _ from 'lodash';
Expand Down
4 changes: 2 additions & 2 deletions src/utils/StrykerTempFolder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as os from 'os';
import * as fs from 'fs';
import * as fs from 'graceful-fs';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
import * as fileUtils from './fileUtils';
Expand Down Expand Up @@ -77,7 +77,7 @@ function writeFile(filename: string, data: string): Promise<void> {
* Copies a file.
* @param fromFilename The path to the existing file.
* @param toFilename The path to copy the file to.
* @param instrumenter An optional additional intrumenter to stream the file through
* @param instrumenter An optional additional instrumenter to stream the file through
* @returns A promise to eventually copy the file.
*/
function copyFile(fromFilename: string, toFilename: string, instrumenter?: NodeJS.ReadWriteStream): Promise<void> {
Expand Down
8 changes: 3 additions & 5 deletions src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

import * as path from 'path';
import * as os from 'os';
import * as fs from 'graceful-fs';
import * as _ from 'lodash';
import fs = require('fs');
import os = require('os');
import path = require('path');
import * as nodeGlob from 'glob';
import * as mkdirp from 'mkdirp';

Expand Down
2 changes: 1 addition & 1 deletion test/integration/utils/fileUtilsSpec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
import * as fs from 'graceful-fs';
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as fileUtils from '../../../src/utils/fileUtils';
Expand Down
8 changes: 4 additions & 4 deletions test/unit/PluginLoaderSpec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import PluginLoader from '../../src/PluginLoader';
import {expect} from 'chai';
import * as path from 'path';
import * as fs from 'graceful-fs';
import * as sinon from 'sinon';
import { expect } from 'chai';
import * as fileUtils from '../../src/utils/fileUtils';
import PluginLoader from '../../src/PluginLoader';
import log from '../helpers/log4jsMock';
import * as fs from 'fs';
import * as path from 'path';

describe('PluginLoader', () => {
let sut: PluginLoader;
Expand Down

0 comments on commit 4c1bf41

Please sign in to comment.