Skip to content

Instantly share code, notes, and snippets.

@tonkotsuboy
Last active January 9, 2019 14:09
Show Gist options
  • Save tonkotsuboy/5e31770e233d3d6eb1c04cc9d45af3b5 to your computer and use it in GitHub Desktop.
Save tonkotsuboy/5e31770e233d3d6eb1c04cc9d45af3b5 to your computer and use it in GitHub Desktop.
Node.jsでキャッシュなしにJSONを読み込む
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