UNPKG

npm-pkg-kit

Version:

CLI tool to simplify NPM package creation by generating boilerplate setup

27 lines (26 loc) 872 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeJSON = exports.readJSON = exports.writeContent = exports.readContent = void 0; const fs_1 = require("fs"); const path_1 = require("path"); function readContent(dir, file) { const path = path_1.join(dir, file); const utf8 = fs_1.readFileSync(path, 'utf8'); return utf8; } exports.readContent = readContent; function writeContent(dir, file, data) { const path = path_1.join(dir, file); fs_1.writeFileSync(path, data, 'utf8'); } exports.writeContent = writeContent; function readJSON(dir, file) { const json = readContent(dir, file); return JSON.parse(json); } exports.readJSON = readJSON; function writeJSON(dir, file, data, indent) { const json = JSON.stringify(data, null, indent); writeContent(dir, file, json); } exports.writeJSON = writeJSON;