Skip to content

Commit

Permalink
No file exists when watching
Browse files Browse the repository at this point in the history
  • Loading branch information
markis committed Feb 1, 2018
1 parent 256bd51 commit b798d97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function watch() {

fs.__addMockFile = __addMockFile;
fs.__resetMockFiles = __resetMockFiles;
fs.existsSync = function() { return false; };
fs.readFileSync = readFileSync;
fs.watch = watch;

Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, watch } from 'fs';
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, watch } from 'fs';

import { getLastError } from './errors';
import {
Expand Down Expand Up @@ -34,6 +34,13 @@ function onRunComplete(globalConfig: Config, options: RatchetOptions) {
const coverageSummaryPath = findCoverageSummaryPath(coverageDirectory);
const jestConfigPath = findJestConfigPath(process.cwd(), process.argv);

if (!existsSync(coverageDirectory)) {
mkdirSync(coverageDirectory);
}
if (!existsSync(coverageSummaryPath)) {
closeSync(openSync(coverageSummaryPath, 'w'));
}

const watcher = watch(coverageDirectory);
watcher.once('change', () => {
watcher.close();
Expand Down

0 comments on commit b798d97

Please sign in to comment.