Skip to content

Commit

Permalink
test: fix typings for utils/fs.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored and Brocco committed Jul 19, 2017
1 parent 826c634 commit 6015f07
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/e2e/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ export function symlinkFile(from: string, to: string, type?: string) {
}

export function createDir(path: string) {
_recursiveMkDir(path);
return _recursiveMkDir(path);
}


function _recursiveMkDir(path: string) {
function _recursiveMkDir(path: string): Promise<void> {
if (fs.existsSync(path)) {
return Promise.resolve();
} else {
Expand All @@ -97,11 +97,11 @@ export function copyFile(from: string, to: string) {
return _recursiveMkDir(dirname(to))
.then(() => new Promise((resolve, reject) => {
const rd = fs.createReadStream(from);
rd.on('error', (err) => reject(err));
rd.on('error', (err: Error) => reject(err));

const wr = fs.createWriteStream(to);
wr.on('error', (err) => reject(err));
wr.on('close', (ex) => resolve());
wr.on('error', (err: Error) => reject(err));
wr.on('close', () => resolve());

rd.pipe(wr);
}));
Expand All @@ -113,8 +113,7 @@ export function writeMultipleFiles(fs: { [path: string]: string }) {
}


export function replaceInFile(filePath: string, match: string, replacement: string);
export function replaceInFile(filePath: string, match: RegExp, replacement: string) {
export function replaceInFile(filePath: string, match: RegExp | string, replacement: string) {
return readFile(filePath)
.then((content: string) => writeFile(filePath, content.replace(match, replacement)));
}
Expand Down

0 comments on commit 6015f07

Please sign in to comment.