Skip to content

Commit 96c4cc0

Browse files
lijunleNicholas Pape
authored andcommitted
Write the TSLint configuration file to the temp directory during build. (microsoft#129)
* Write the TSLint configuration file when execute. - The TSLint configuration file can be used for VSCode TSLint plugin. * Run rush change. * Replace with fs.writeFileSync * Leverage the writeFileSync. - Leave a TODO to improve the performance. * Update the change set comment. * Fix some problems * Merge
1 parent b966aed commit 96c4cc0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/gulp-core-build-typescript",
5+
"comment": "Write the TSLint configuration file after executing the task.",
6+
"type": "minor"
7+
}
8+
],
9+
"email": "lijunle@users.noreply.github.com"
10+
}

gulp-core-build-typescript/src/TSLintTask.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { GulpTask } from '@microsoft/gulp-core-build';
1+
import { GulpTask, IBuildConfig } from '@microsoft/gulp-core-build';
22
import gulpType = require('gulp');
33
/* tslint:disable:typedef */
44
const md5 = require('md5');
55
const merge = require('lodash').merge;
66
/* tslint:enable:typedef */
77
import through2 = require('through2');
88
import gutil = require('gulp-util');
9+
import * as fs from 'fs';
910
import * as TSLint from 'tslint';
1011
import * as path from 'path';
1112
import * as ts from 'typescript';
@@ -115,6 +116,13 @@ export class TSLintTask extends GulpTask<ITSLintTaskConfig> {
115116
const taskScope: TSLintTask = this;
116117

117118
const activeLintRules: any = taskScope._loadLintRules(); // tslint:disable-line:no-any
119+
120+
// Write out the active lint rules for easier debugging
121+
if (!fs.existsSync(path.dirname(this._getTsLintFilepath()))) {
122+
fs.mkdirSync(path.dirname(this._getTsLintFilepath()));
123+
}
124+
fs.writeFileSync(this._getTsLintFilepath(), JSON.stringify(activeLintRules, undefined, 2));
125+
118126
const cached = require('gulp-cache'); // tslint:disable-line
119127

120128
return gulp.src(this.taskConfig.sourceMatch)
@@ -181,6 +189,14 @@ export class TSLintTask extends GulpTask<ITSLintTaskConfig> {
181189
));
182190
}
183191

192+
public getCleanMatch(buildConfig: IBuildConfig, taskConfig: ITSLintTaskConfig = this.taskConfig): string[] {
193+
return [path.join(buildConfig.rootPath, buildConfig.tempFolder)];
194+
}
195+
196+
private _getTsLintFilepath(): string {
197+
return path.join(this.buildConfig.rootPath, this.buildConfig.tempFolder, 'tslint.json');
198+
}
199+
184200
private _loadLintRules(): any { // tslint:disable-line:no-any
185201
if (!this._defaultLintRules) {
186202
this._defaultLintRules = require('./defaultTslint.json');

0 commit comments

Comments
 (0)