Skip to content

Commit 48fda1d

Browse files
author
Gerard Delmàs
committed
use let/const
1 parent 7e5ad20 commit 48fda1d

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/DtsContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class DtsContent {
6969
}
7070

7171
public async writeFile(): Promise<void> {
72-
var outPathDir = path.dirname(this.outputFilePath);
72+
const outPathDir = path.dirname(this.outputFilePath);
7373
if(!isThere(outPathDir)) {
7474
mkdirp.sync(outPathDir);
7575
}

src/DtsCreator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ export class DtsCreator {
5454

5555
const res = await this.loader.fetch(filePath, "/", undefined, initialContents);
5656
if(res) {
57-
var tokens = res;
58-
var keys = Object.keys(tokens);
57+
const tokens = res;
58+
const keys = Object.keys(tokens);
5959

60-
var convertKey = this.getConvertKeyMethod(this.camelCase);
60+
const convertKey = this.getConvertKeyMethod(this.camelCase);
6161

62-
var result = keys
62+
const result = keys
6363
.map(k => convertKey(k))
6464
.map(k => 'readonly "' + k + '": string;')
6565

66-
var content = new DtsContent({
66+
const content = new DtsContent({
6767
dropExtension: this.dropExtension,
6868
rootDir: this.rootDir,
6969
searchDir: this.searchDir,

src/FileSystemLoader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export default class FileSystemLoader {
3030
}
3131

3232
public async fetch(_newPath: string, relativeTo: string, _trace?: string, initialContents?: string): Promise<Core.ExportTokens> {
33-
let newPath = _newPath.replace(/^["']|["']$/g, "");
34-
let trace = _trace || String.fromCharCode(this.importNr++);
33+
const newPath = _newPath.replace(/^["']|["']$/g, "");
34+
const trace = _trace || String.fromCharCode(this.importNr++);
3535

36-
let relativeDir = path.dirname(relativeTo);
37-
let rootRelativePath = path.resolve(relativeDir, newPath);
36+
const relativeDir = path.dirname(relativeTo);
37+
const rootRelativePath = path.resolve(relativeDir, newPath);
3838
let fileRelativePath = path.resolve(path.join(this.root, relativeDir), newPath);
3939

4040
// if the path is not relative or absolute, try to resolve it in node_modules

src/cli.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import chalk from 'chalk';
88
import {DtsCreator} from './DtsCreator';
99
import {DtsContent} from "./DtsContent";
1010

11-
let yarg = yargs.usage('Create .css.d.ts from CSS modules *.css files.\nUsage: $0 [options] <input directory>')
11+
const yarg = yargs.usage('Create .css.d.ts from CSS modules *.css files.\nUsage: $0 [options] <input directory>')
1212
.example('$0 src/styles', '')
1313
.example('$0 src -o dist', '')
1414
.example('$0 -p styles/**/*.icss -w', '')
@@ -22,7 +22,7 @@ let yarg = yargs.usage('Create .css.d.ts from CSS modules *.css files.\nUsage: $
2222
.alias('s', 'silent').describe('s', 'Silent output. Do not show "files written" messages').boolean('s')
2323
.alias('h', 'help').help('h')
2424
.version(() => require('../package.json').version);
25-
let argv = yarg.argv;
25+
const argv = yarg.argv;
2626
let creator: DtsCreator;
2727

2828
async function writeFile(f: string): Promise<void> {
@@ -39,8 +39,9 @@ async function writeFile(f: string): Promise<void> {
3939
}
4040
};
4141

42-
let main = () => {
43-
let rootDir, searchDir;
42+
function main() {
43+
let rootDir: string;
44+
let searchDir: string;
4445
if(argv.h) {
4546
yarg.showHelp();
4647
return;
@@ -54,7 +55,7 @@ let main = () => {
5455
yarg.showHelp();
5556
return;
5657
}
57-
let filesPattern = path.join(searchDir, argv.p || '**/*.css');
58+
const filesPattern = path.join(searchDir, argv.p || '**/*.css');
5859
rootDir = process.cwd();
5960
creator = new DtsCreator({
6061
rootDir,
@@ -76,7 +77,7 @@ let main = () => {
7677
} else {
7778
console.log('Watch ' + filesPattern + '...');
7879

79-
var watcher = chokidar.watch([filesPattern.replace(/\\/g, "/")]);
80+
const watcher = chokidar.watch([filesPattern.replace(/\\/g, "/")]);
8081
watcher.on('add', writeFile);
8182
watcher.on('change', writeFile);
8283
}

0 commit comments

Comments
 (0)