This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from JoshuaKGoldberg/settings-refactor
Settings refactor
- Loading branch information
Showing
10 changed files
with
166 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
namespace TSLint.MSBuild { | ||
"use strict"; | ||
|
||
/** | ||
* A parser and storer for command-line arguments to TSLint.MSBuild. | ||
*/ | ||
export class ArgumentsCollection { | ||
/** | ||
* Value setters for arguments, keyed by alias. | ||
*/ | ||
private static valueSetters: { [i: string]: (value: string) => void } = { | ||
"exclude": ArgumentsCollection.prototype.setExclude, | ||
"files-root-dir": ArgumentsCollection.prototype.setFilesRootDir, | ||
"file-list-file": ArgumentsCollection.prototype.setFileListFile | ||
}; | ||
|
||
/** | ||
* A glob path to exclude from linting. | ||
* | ||
* @alias exclude | ||
*/ | ||
private exclude: RegExp; | ||
|
||
/** | ||
* A root directory to work within. | ||
* | ||
* @alias files-root-dir | ||
*/ | ||
private filesRootDir: string; | ||
|
||
/** | ||
* The path to the file listing files to be linted. | ||
* | ||
* @alias file-list-file | ||
*/ | ||
private fileListFile: string; | ||
|
||
/** | ||
* Initializes a new instance of the ArgumentsCollection class. | ||
* | ||
* @param inputs Raw command-line input. | ||
*/ | ||
constructor(inputs: string[]) { | ||
for (let i: number = 0; i < inputs.length; i += 2) { | ||
const alias = inputs[i].replace("-", ""); | ||
const value = inputs[i + 1]; | ||
|
||
if (!ArgumentsCollection.valueSetters.hasOwnProperty(alias)) { | ||
throw new Error(`Unknown TSLint.MSBuild argument: '${inputs[i]}' '${value}'`); | ||
} | ||
|
||
console.log(`Setting '${alias}' to '${value}'.`); | ||
ArgumentsCollection.valueSetters[alias].call(this, value); | ||
} | ||
} | ||
|
||
/** | ||
* @returns The FilesRootDir argument. | ||
*/ | ||
public getFilesRootDir(): string { | ||
return this.filesRootDir; | ||
} | ||
|
||
/** | ||
* @returns The FileListFile argument. | ||
*/ | ||
public getFileListFile(): string { | ||
return this.fileListFile; | ||
} | ||
|
||
/** | ||
* @returns The Exclude argument. | ||
*/ | ||
public getExclude(): RegExp { | ||
return this.exclude; | ||
} | ||
|
||
/** | ||
* Sets the FilesRootDir argument. | ||
* | ||
* @param value A new FilesRootDir value. | ||
*/ | ||
private setFilesRootDir(value: string): void { | ||
this.filesRootDir = value; | ||
} | ||
|
||
/** | ||
* Sets the FileListFile argument. | ||
* | ||
* @param value A new FileListFile value. | ||
*/ | ||
private setFileListFile(value: string): void { | ||
this.fileListFile = value; | ||
} | ||
|
||
/** | ||
* Sets the Exclude argument. | ||
* | ||
* @param value A new Exclude value. | ||
*/ | ||
private setExclude(value: string): void { | ||
this.exclude = new RegExp(value || "^$", "i"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.