Skip to content

Commit

Permalink
fix: promisfy fs.access in getSystemPath
Browse files Browse the repository at this point in the history
  • Loading branch information
dkphung authored and nodkz committed Dec 22, 2018
1 parent 427a01d commit 85af3cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/util/MongoBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import mkdirp from 'mkdirp';
import findCacheDir from 'find-cache-dir';
import { execSync } from 'child_process';
import dedent from 'dedent';
import { promisify } from 'util';
import MongoBinaryDownload from './MongoBinaryDownload';

export type MongoBinaryCache = {
Expand All @@ -30,12 +31,12 @@ export default class MongoBinary {
let binaryPath: string = '';

try {
await fs.access(systemBinary);
await promisify(fs.access)(systemBinary);

this.debug(`MongoBinary: found sytem binary path at ${systemBinary}`);
binaryPath = systemBinary;
} catch (err) {
this.debug(`MongoBinary: can't find system binary at ${systemBinary}`);
this.debug(`MongoBinary: can't find system binary at ${systemBinary}. ${err.message}`);
}

return binaryPath;
Expand Down
4 changes: 2 additions & 2 deletions src/util/__tests__/MongoBinary-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('MongoBinary', () => {
process.env.MONGOMS_SYSTEM_BINARY = '/usr/local/bin/mongod';
await MongoBinary.getPath();

expect(accessSpy).toHaveBeenCalledWith('/usr/local/bin/mongod');
expect(accessSpy).toHaveBeenCalledWith('/usr/local/bin/mongod', expect.any(Function));

accessSpy.mockClear();
});
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('MongoBinary', () => {
const accessSpy = jest.spyOn(fs, 'access');
await MongoBinary.getSystemPath('/usr/bin/mongod');

expect(accessSpy).toHaveBeenCalledWith('/usr/bin/mongod');
expect(accessSpy).toHaveBeenCalledWith('/usr/bin/mongod', expect.any(Function));

accessSpy.mockClear();
});
Expand Down

0 comments on commit 85af3cf

Please sign in to comment.