UNPKG

@softwareventures/maintain-project

Version:

Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited

29 lines 1.53 kB
import { mapNullable, mapNullableFn, mapNullFn } from "@softwareventures/nullable"; import { mapFn } from "@softwareventures/array"; import { findExtract } from "../collections/arrays.js"; import { toNullable } from "../result/result.js"; import { insert } from "../fs-stage/fs-stage.js"; import { readProjectScript } from "./read-script.js"; import { modifyProjectScript } from "./modify-script.js"; export async function removeTslintFromTestScript(project) { const existingScript = readProjectScript(project, "test"); const commands = existingScript .then(mapNullableFn(script => script.split("&&"))) .then(mapNullableFn(mapFn(command => command.trim()))) .then(mapNullFn(() => [])); const newCommands = commands .then(commands => { const [tslintCommand, newCommands] = findExtract(commands, command => Boolean(command.match(/^tslint(\s|$)/u))); return mapNullable(tslintCommand, () => newCommands); }) .then(mapNullableFn(commands => (commands.length === 0 ? ["echo No tests yet"] : commands))); const file = newCommands .then(mapNullableFn(async (commands) => modifyProjectScript(project, "test", () => commands.join(" && ")))) .then(mapNullableFn(toNullable)); return file.then(mapNullableFn(file => ({ type: "fs-stage-update", log: "build(npm): remove tslint from test script", apply: async (stage) => insert(stage, "package.json", file) }))); } //# sourceMappingURL=remove-tslint-from-test-script.js.map