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

Commit

Permalink
fix: use async fs.stat
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 5, 2021
1 parent a8d5b1c commit fb51a78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
16 changes: 8 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { CompositeDisposable } from 'atom';
import path from 'path';
import fs from 'fs';
import { promises } from 'fs';
const { stat } = promises;
import WorkerHelper from './workerHelper';

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

// Config subscriptions
this.subscriptions.add(
atom.config.observe('linter-tslint.rulesDirectory', (dir) => {
atom.config.observe('linter-tslint.rulesDirectory', async (dir) => {
if (dir && path.isAbsolute(dir)) {
fs.stat(dir, (err, stats) => {
if (stats && stats.isDirectory()) {
config.rulesDirectory = dir;
this.workerHelper.changeConfig('rulesDirectory', dir);
}
});
const stats = await stat(dir);
if (stats && stats.isDirectory()) {
config.rulesDirectory = dir;
this.workerHelper.changeConfig('rulesDirectory', dir);
}
}
}),
atom.config.observe('linter-tslint.useLocalTslint', (use) => {
Expand Down
14 changes: 2 additions & 12 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

/* global emit */

import fs from 'fs';
import { promises } from 'fs';
const { stat } = promises;
import path from 'path';
import { getRuleUri } from 'tslint-rule-documentation';
import ChildProcess from 'child_process';
Expand All @@ -19,17 +20,6 @@ const config = {
let fallbackLinter;
let requireResolve;

function stat(pathname) {
return new Promise((resolve, reject) => {
fs.stat(pathname, (err, stats) => {
if (err) {
return reject(err);
}
return resolve(stats);
});
});
}

/**
* Shim for TSLint v3 interoperability
* @param {Function} Linter TSLint v3 linter
Expand Down

0 comments on commit fb51a78

Please sign in to comment.