-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a `rootDir` option (`--rootDir` or `-r` on the command line) to specify the root directory of the project. (It defaults to the current working directory.) This also refactors options a bit: the options object is now stored so that it can be accessed globally via `getOptions()`, and when storing it paths are normalized and defaults filled in for missing values.
- Loading branch information
Showing
6 changed files
with
29 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as path from 'path'; | ||
import Options from './types/Options'; | ||
|
||
let options: Options; | ||
|
||
export default function getOptions() { | ||
return options; | ||
} | ||
|
||
export function setOptions(providedOptions: Options) { | ||
options = providedOptions; | ||
|
||
// Normalize and apply defaults | ||
options.rootDir = options.rootDir ? path.resolve(options.rootDir) : path.resolve(); | ||
options.project = options.project | ||
? path.resolve(options.project) | ||
: path.resolve(options.rootDir, 'tsconfig.json'); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export default interface Options { | ||
project?: string; | ||
rootDir?: string; | ||
onError?: (message: string) => void; | ||
}; |