UNPKG

rush-sort-package-json

Version:

Rush plugin for sort package.json file in the project

19 lines 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.sortPackageJson = void 0; var path_1 = __importDefault(require("path")); var node_core_library_1 = require("@rushstack/node-core-library"); var sort_package_json_1 = __importDefault(require("sort-package-json")); var sortPackageJson = function (projectPath) { var packageJsonFilePath = path_1.default.resolve(projectPath, "package.json"); if (!node_core_library_1.FileSystem.exists(packageJsonFilePath)) { throw new Error("package.json for ".concat(packageJsonFilePath, " does not exist")); } var input = node_core_library_1.FileSystem.readFile(packageJsonFilePath); node_core_library_1.FileSystem.writeFile(packageJsonFilePath, (0, sort_package_json_1.default)(input)); }; exports.sortPackageJson = sortPackageJson; //# sourceMappingURL=sortPackageJson.js.map