forked from JoshuaKGoldberg/TSLint.MSBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes casing in comments. Issue : JoshuaKGoldberg#17
- Loading branch information
Arnaud Dufranne
committed
Apr 18, 2016
1 parent
fe7994b
commit 3b2570b
Showing
5 changed files
with
36 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
/// <reference path="../typings/main/ambient/node/index.d.ts" /> | ||
|
||
namespace TSLint.MSBuild.ConfigLoader { | ||
namespace TSLint.MSBuild { | ||
"use strict"; | ||
|
||
const fs = require("fs"), | ||
path = require("path"); | ||
|
||
/** | ||
* Reads and deserializes a tslint.json file. | ||
* @param path The path of the file. | ||
* @returns A promise with the configuration object. | ||
*/ | ||
export function readJSONConfig(path: string) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, (error, result) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(JSON.parse(stripBomIfNeeded(result.toString()))); | ||
} | ||
export class ConfigLoader { | ||
|
||
/** | ||
* Reads and deserializes a tslint.json file. | ||
* @param path The path of the file. | ||
* @returns A promise with the configuration object. | ||
*/ | ||
public readJSONConfig(path: string) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, (error, result) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(JSON.parse(ConfigLoader.stripBomIfNeeded(result.toString()))); | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Strips BOM if any. | ||
* @param content the raw content of a file. | ||
* @returns The content with the BOM stripped. | ||
*/ | ||
function stripBomIfNeeded(content: string) { | ||
return content.replace(/^\uFEFF/, ""); | ||
/** | ||
* Strips BOM if any. | ||
* @param content the raw content of a file. | ||
* @returns The content with the BOM stripped. | ||
*/ | ||
static stripBomIfNeeded(content: string) { | ||
return content.replace(/^\uFEFF/, ""); | ||
} | ||
} | ||
} |
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