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

Commit

Permalink
Merge pull request #1084 from palantir/config-cli-behavior
Browse files Browse the repository at this point in the history
Treat all -c option CLI values as a path
  • Loading branch information
adidahiya committed Apr 5, 2016
2 parents 3281470 + b0bc2cd commit 8ea204b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tslint-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import * as fs from "fs";
import * as glob from "glob";
import * as optimist from "optimist";
import * as path from "path";
import * as Linter from "./tslint";
import {
CONFIG_FILENAME,
Expand Down Expand Up @@ -196,6 +197,7 @@ if (argv.c && !fs.existsSync(argv.c)) {
console.error("Invalid option for configuration: " + argv.c);
process.exit(1);
}
const possibleConfigAbsolutePath = argv.c != null ? path.resolve(argv.c) : null;

const processFile = (file: string) => {
if (!fs.existsSync(file)) {
Expand All @@ -204,7 +206,7 @@ const processFile = (file: string) => {
}

const contents = fs.readFileSync(file, "utf8");
const configuration = findConfiguration(argv.c, file);
const configuration = findConfiguration(possibleConfigAbsolutePath, file);

const linter = new Linter(file, contents, {
configuration,
Expand Down
4 changes: 4 additions & 0 deletions test/check-bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ expectOut $? 2 "tslint with with JSON pointing to two custom rules did not find
./bin/tslint -c ./test/config/tslint-custom-rules.json -r ./test/files/custom-rules --force src/tslint.ts
expectOut $? 0 "tslint with with -r pointing to custom rules did not find lint failures"

# make sure path to config without a preceding "./" works on the CLI
./bin/tslint -c test/config/tslint-almost-empty.json src/tslint.ts
expectOut $? 0 "-c relative path without ./ did not work"

# make sure tslint --init generates a file
cd ./bin
if [ -f tslint.json ]; then
Expand Down
1 change: 1 addition & 0 deletions test/config/tslint-almost-empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "rules": {} }

0 comments on commit 8ea204b

Please sign in to comment.