Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replace-in-files-cli

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replace-in-files-cli - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

26

api.js

@@ -1,12 +0,10 @@

'use strict';
const {promisify} = require('util');
const path = require('path');
const fs = require('fs');
const normalizePath = process.platform === 'win32' ? require('normalize-path') : x => x;
const writeFileAtomic = require('write-file-atomic');
const escapeStringRegexp = require('escape-string-regexp');
const arrify = require('arrify');
const globby = require('globby');
import process from 'node:process';
import path from 'node:path';
import {promises as fsPromises} from 'node:fs';
import normalizePath_ from 'normalize-path';
import writeFileAtomic from 'write-file-atomic';
import escapeStringRegexp from 'escape-string-regexp';
import {globby} from 'globby';
const readFile = promisify(fs.readFile);
const normalizePath = process.platform === 'win32' ? normalizePath_ : x => x;

@@ -16,4 +14,4 @@ // TODO(sindresorhus): I will extract this to a separate module at some point when it's more mature.

// The `ignoreCase` option overrides the `i` flag for regexes in `find`
module.exports = async (filePaths, {find, replacement, ignoreCase, glob} = {}) => {
filePaths = arrify(filePaths);
export default async function replaceInFiler(filePaths, {find, replacement, ignoreCase, glob} = {}) {
filePaths = [filePaths].flat();

@@ -52,3 +50,3 @@ if (filePaths.length === 0) {

await Promise.all(filePaths.map(async filePath => {
const string = await readFile(filePath, 'utf8');
const string = await fsPromises.readFile(filePath, 'utf8');

@@ -66,2 +64,2 @@ let newString = string;

}));
};
}
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const replaceInFiles = require('./api');
import process from 'node:process';
import meow from 'meow';
import replaceInFiles from './api.js';

@@ -24,24 +24,25 @@ const cli = meow(`

`, {
importMeta: import.meta,
flags: {
regex: {
type: 'string',
isMultiple: true
isMultiple: true,
},
string: {
type: 'string',
isMultiple: true
isMultiple: true,
},
replacement: {
type: 'string',
isRequired: true
isRequired: true,
},
ignoreCase: {
type: 'boolean',
default: false
default: false,
},
glob: {
type: 'boolean',
default: true
}
}
default: true,
},
},
});

@@ -62,10 +63,9 @@

find: [
// TODO: Remove the `|| []` when `meow` 7.1.2 is out.
...(cli.flags.string || []),
...(cli.flags.regex || []).map(regexString => new RegExp(regexString, 'g'))
...cli.flags.string,
...cli.flags.regex.map(regexString => new RegExp(regexString, 'g')),
],
replacement: cli.flags.replacement,
ignoreCase: cli.flags.ignoreCase,
glob: cli.flags.glob
glob: cli.flags.glob,
});
})();
{
"name": "replace-in-files-cli",
"version": "1.0.0",
"version": "2.0.0",
"description": "Replace matching strings and regexes in files",

@@ -13,7 +13,8 @@ "license": "MIT",

},
"type": "module",
"bin": {
"replace-in-files": "cli.js"
"replace-in-files": "./cli.js"
},
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -46,15 +47,14 @@ "scripts": {

"dependencies": {
"arrify": "^2.0.1",
"escape-string-regexp": "^4.0.0",
"globby": "^11.0.1",
"meow": "^7.1.1",
"escape-string-regexp": "^5.0.0",
"globby": "^12.0.2",
"meow": "^10.1.1",
"normalize-path": "^3.0.0",
"write-file-atomic": "^3.0.0"
"write-file-atomic": "^3.0.3"
},
"devDependencies": {
"ava": "^2.1.0",
"execa": "^1.0.0",
"temp-write": "^4.0.0",
"xo": "^0.33.1"
"ava": "^3.15.0",
"execa": "^5.1.1",
"temp-write": "^5.0.0",
"xo": "^0.46.4"
}
}

@@ -1,2 +0,2 @@

# replace-in-files-cli [![Build Status](https://travis-ci.com/sindresorhus/replace-in-files-cli.svg?branch=master)](https://travis-ci.com/github/sindresorhus/replace-in-files-cli)
# replace-in-files-cli

@@ -7,5 +7,5 @@ > Replace matching strings and regexes in files

```sh
npm install --global replace-in-files-cli
```
$ npm install --global replace-in-files-cli
```

@@ -12,0 +12,0 @@ ## Usage

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc