Last active
January 9, 2019 14:09
-
-
Save tonkotsuboy/5e31770e233d3d6eb1c04cc9d45af3b5 to your computer and use it in GitHub Desktop.
Node.jsでキャッシュなしに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
import fs from "fs"; | |
/** | |
* Node.jsでキャッシュなしにJSONを読み込む | |
* | |
* 使用例 | |
* import path from "path"; | |
* | |
* const myStubJson = parseJsonWithoutCache( | |
* path.resolve(__dirname, "relative_path_to_json") | |
* ); | |
* | |
* @param resolvedFilePath | |
*/ | |
export function parseJsonWithoutCache(resolvedFilePath: string): object { | |
const readJson = fs.readFileSync(resolvedFilePath, "utf8"); | |
return JSON.parse(readJson); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment