Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit fb51a78

Browse files
committed
fix: use async fs.stat
1 parent a8d5b1c commit fb51a78

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

lib/main.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import { CompositeDisposable } from 'atom';
44
import path from 'path';
5-
import fs from 'fs';
5+
import { promises } from 'fs';
6+
const { stat } = promises;
67
import WorkerHelper from './workerHelper';
78

89
const grammarScopes = ['source.ts', 'source.tsx'];
@@ -40,14 +41,13 @@ const TsLintPackage = {
4041

4142
// Config subscriptions
4243
this.subscriptions.add(
43-
atom.config.observe('linter-tslint.rulesDirectory', (dir) => {
44+
atom.config.observe('linter-tslint.rulesDirectory', async (dir) => {
4445
if (dir && path.isAbsolute(dir)) {
45-
fs.stat(dir, (err, stats) => {
46-
if (stats && stats.isDirectory()) {
47-
config.rulesDirectory = dir;
48-
this.workerHelper.changeConfig('rulesDirectory', dir);
49-
}
50-
});
46+
const stats = await stat(dir);
47+
if (stats && stats.isDirectory()) {
48+
config.rulesDirectory = dir;
49+
this.workerHelper.changeConfig('rulesDirectory', dir);
50+
}
5151
}
5252
}),
5353
atom.config.observe('linter-tslint.useLocalTslint', (use) => {

lib/worker.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
/* global emit */
44

5-
import fs from 'fs';
5+
import { promises } from 'fs';
6+
const { stat } = promises;
67
import path from 'path';
78
import { getRuleUri } from 'tslint-rule-documentation';
89
import ChildProcess from 'child_process';
@@ -19,17 +20,6 @@ const config = {
1920
let fallbackLinter;
2021
let requireResolve;
2122

22-
function stat(pathname) {
23-
return new Promise((resolve, reject) => {
24-
fs.stat(pathname, (err, stats) => {
25-
if (err) {
26-
return reject(err);
27-
}
28-
return resolve(stats);
29-
});
30-
});
31-
}
32-
3323
/**
3424
* Shim for TSLint v3 interoperability
3525
* @param {Function} Linter TSLint v3 linter

0 commit comments

Comments
 (0)