npm.io
1.1.0 • Published 5 years agoCLI

replace-in-path

Licence
MIT
Version
1.1.0
Deps
1
Size
188 kB
Vulns
0
Weekly
0

Build code style: prettier PRs Welcome

Install

npm install replace-in-path --save-dev

Or if you prefer yarn:

yarn add replace-in-path --dev

Quick Example:

const codeReplacements = [
    {
        find: `const { security } = this.context;`,
        replaceWith: `// const { security } = this.context;`,
    },
    {
        find: "const identity = await security.getIdentity",
        replaceWith: "// const identity = await security.getIdentity",
    },
    {
        find: new RegExp("createdBy: identity.*},", "gms"),
        replaceWith: "/* __CODE_BLOCK_2__amp; */",
    },
];

replaceInPath(
    path.join(newCodePath, "/resolvers/TargetDataModelsMutation.ts"),
    codeReplacements
);

Keywords