Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Added MSBuild property overriding, and updated readme
Browse files Browse the repository at this point in the history
Fixes #13.
  • Loading branch information
Josh Goldberg committed Apr 4, 2016
1 parent e77ecb6 commit 67d6f7d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ An MSBuild wrapper around Palantir's wonderful [tslint](https://github.com/palan

## Usage

Add a link the package's targets file in your project's .csproj file:
Add this package using the Visual Studio's NuGet Package Manager.
It should be automatically added to your project.

```xml
<Import Project="..\packages\TSLint.MSBuild.0.1.0\build\TSLint.MSBuild.targets" Condition="Exists('..\packages\TSLint.MSBuild.0.1.0\build\TSLint.MSBuild.targets')" />
```
### Builds

At runtime, the list of .ts files from your build (`TypeScriptCompile`) is output to a temporary .txt file.
A .js runner file then takes in the path to that file list, scans for `tslint.json` files, and runs TSLint on each .ts file.

*If you're unsure of where to put it, directly above the TypeScript targets import is fine.*
The following properties may be overidden via your targets:
* **TSLintDeleteFileListFile** - Whether to delete the file list file when done. Defaults to `true`.
* **TSLintFileListDir** - The directory to put the file list in. Defaults to `$(IntermediateOutDir)`.
* **TSLintFileListName** - The name of the file list file. Defaults to `TSLintFileList.txt`.
* **TSLintNodeExe**: A node executable to execute the runner script. Defaults to the `tools\node-5.9.0.exe` in the package.
* **TSLintRunnerScript** - The .js file to take in `TSLintFileListFile`. Defaults to the `tools\runner.js` in the package.

### tslint.json

Expand Down
18 changes: 11 additions & 7 deletions src/TSLint.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@
Condition="'@(TypeScriptCompile)' != ''"
Name="TSLint">
<PropertyGroup>
<NodeExe>$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)\..\tools\node-5.9.0.exe"))</NodeExe>
<RunnerScript>$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)\..\tools\runner.js"))</RunnerScript>
<TSLintFileListFilename>$(IntermediateOutDir)TSLintFileList.txt</TSLintFileListFilename>
<TSLintDeleteFileListFile Condition="'$(TSLintDeleteFileListFile)' == ''">true</TSLintDeleteFileListFile>
<TSLintFileListDir Condition="'$(TSLintFileListDir)' == ''">$(IntermediateOutDir)</TSLintFileListDir>
<TSLintFileListName Condition="'$(TSLintFileListName)' == ''">TSLintFileList.txt</TSLintFileListName>
<TSLintFileListFile>$(TSLintFileListDir)$(TSLintFileListName)</TSLintFileListFile>
<TSLintNodeExe Condition="'$(TSLintNodeExe)' == ''">$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)\..\tools\node-5.9.0.exe"))</TSLintNodeExe>
<TSLintRunnerScript Condition="'$(TSLintRunnerScript)' == ''">$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)\..\tools\runner.js"))</TSLintRunnerScript>
</PropertyGroup>

<ItemGroup>
<TSLintFile Include="@(TypeScriptCompile)" />
</ItemGroup>

<!-- Write file names to a text file so the runner can read them -->
<MakeDir Directories="$(TSLintFileListDir)" />
<WriteLinesToFile
File="$(TSLintFileListFilename)"
File="$(TSLintFileListFile)"
Lines="@(TSLintFile->'%(Identity)')"
Overwrite="true" />

<!-- Run TSLint -->
<!-- Run TSLint via the runner -->
<Exec
Command="&quot;$(NodeExe)&quot; --harmony &quot;$(RunnerScript)&quot; &quot;$(TSLintFileListFilename)&quot;"
Command="&quot;$(TSLintNodeExe)&quot; --harmony &quot;$(TSLintRunnerScript)&quot; &quot;$(TSLintFileListFile)&quot;"
IgnoreExitCode="true" />

<!-- Clean up our compiled file list when done -->
<Delete Files="$(TSLintFileListFilename)" />
<Delete Condition="'$(TSLintDeleteFileListFile)' == 'true'" Files="$(TSLintFileListFile)" />
</Target>
</Project>

0 comments on commit 67d6f7d

Please sign in to comment.