@frsource/frs-replace 4.0.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -100,6 +100,7 @@ frs-replace <regex> <replacement> [options]
100
100
  |&#8209;i, &#8209;&#8209;input | string or string[] | *-* | Path to files or [fast-glob](https://github.com/mrmlnc/fast-glob) pattern pointing to files to be read & replaced from. If multiple files specified results will be joined using `outputJoinString` option's value) |
101
101
  | &#8209;&#8209;i-read-opts | string or object | utf8 | Options which are passed directly to the [readFileSync method](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) when reading input file |
102
102
  | &#8209;&#8209;i-glob-opts | object | *undefined* | Options which are passed directly to the [fast-glob package](https://github.com/mrmlnc/fast-glob#options-1) when resolving glob patterns |
103
+ | &#8209;&#8209;stdin | boolean | *true* | Wait for stdin input (should be set to *false* when used in non-interactive terminals) |
103
104
  | &#8209;o, &#8209;&#8209;output | string | *-* | Output file name/path (replaces the file if it already exists and creates any intermediate directories if they don't already exist) |
104
105
  | &#8209;&#8209;o-write-opts | string or object | utf8 | Passed as options argument of [write's .sync](https://www.npmjs.com/package/write#sync) |
105
106
  | &#8209;&#8209;o-join-str | string | \n | Used when joining multiple files, passed directly to [javascript join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join#Syntax) |
package/bin/cli.js CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
- const replaceSync = require('../sync')
2
+ const replaceSync = require('../sync');
3
3
 
4
- require('get-stdin')().then((stdin) => {
4
+ (
5
+ ~process.argv.indexOf('--no-stdin')
6
+ ? Promise.resolve()
7
+ : require('get-stdin')()
8
+ ).then((stdin) => {
5
9
  const isPiped = !!stdin
6
10
 
7
11
  if (isPiped) {
@@ -48,7 +52,6 @@ require('get-stdin')().then((stdin) => {
48
52
  .choices('f', ['', 'g', 'm', 'i', 'gm', 'gi', 'mi', 'mg', 'ig', 'im', 'gmi', 'gim', 'mig', 'mgi', 'igm', 'img'])
49
53
  .default('f', 'g')
50
54
  .coerce('f', arg => arg.trim())
51
-
52
55
  .option('i', { demandOption: !isContentPresent && !isHelpPresent })
53
56
  .alias('i', 'input')
54
57
  .describe('i', 'Path to files or fast-glob pattern pointing to files to read & replace from')
@@ -63,6 +66,11 @@ require('get-stdin')().then((stdin) => {
63
66
  .describe('i-glob-opts', 'Passed to fast-glob.sync when resolving glob patterns')
64
67
  .implies('i-glob-opts', 'i')
65
68
 
69
+ .option('stdin')
70
+ .describe('stdin', 'Wait for stdin input (should be set to false when used in non-interactive terminals)')
71
+ .boolean('stdin')
72
+ .default('stdin', true)
73
+
66
74
  .option('c', { demandOption: isContentPresent })
67
75
  .alias('c', 'content')
68
76
  .describe('c', 'Content to be replaced (takes precedence over stream & file input)')
@@ -120,7 +128,7 @@ require('get-stdin')().then((stdin) => {
120
128
  inputReadOptions: argv['i-read-opts'],
121
129
  inputGlobOptions: argv['i-glob-opts'],
122
130
  content: argv.c,
123
- strategy: argv.strategy,
131
+ strategy: argv.s,
124
132
  output: argv.o,
125
133
  outputWriteOptions: argv['o-write-opts'],
126
134
  outputJoinString: argv['o-join-str'],
@@ -133,7 +141,7 @@ require('get-stdin')().then((stdin) => {
133
141
  }
134
142
 
135
143
  return process.exit()
136
- } catch (e) /* istanbul ignore next */ {
144
+ } catch (e) /* c8 ignore next */ {
137
145
  process.stderr.write(e.toString())
138
146
  return process.exit(1)
139
147
  }
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@frsource/frs-replace",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "Simple wrapper around javascript replace with CLI usage support!",
5
5
  "bin": {
6
6
  "frs-replace": "./bin/cli.js"
7
7
  },
8
8
  "main": "index.js",
9
- "repository": "https://github.com/FRSource/frs-replace.git",
9
+ "repository": "https://github.com/FRSOURCE/frs-replace.git",
10
10
  "author": "Jakub Freisler <FRSgit@users.noreply.github.com>",
11
11
  "license": "Apache-2.0",
12
+ "packageManager": "pnpm@8.5.1",
12
13
  "bugs": {
13
- "url": "https://github.com/FRSource/frs-replace/issues"
14
+ "url": "https://github.com/FRSOURCE/frs-replace/issues"
14
15
  },
15
- "homepage": "https://github.com/FRSource/frs-replace#readme",
16
+ "homepage": "https://github.com/FRSOURCE/frs-replace#readme",
16
17
  "files": [
17
18
  "bin/cli.js",
18
19
  "src/sync.js",
@@ -22,8 +23,7 @@
22
23
  "async.js",
23
24
  "index.js",
24
25
  "LICENSE",
25
- "package.json",
26
- "yarn.lock"
26
+ "package.json"
27
27
  ],
28
28
  "keywords": [
29
29
  "replace",
@@ -40,35 +40,31 @@
40
40
  "regular-expression",
41
41
  "javascript"
42
42
  ],
43
- "scripts": {
44
- "prerelease": "yarn standard:fix && yarn test",
45
- "release": "standard-version",
46
- "postrelease": "git push --follow-tags origin master && yarn publish",
47
- "pretest": "standard",
48
- "test": "yarn test:unit --100",
49
- "posttest": "tap --coverage-report=html",
50
- "pretest:unit": "yarn standard:fix",
51
- "test:unit": "tap ./src/*.test.js ./bin/*.test.js -J",
52
- "test:unit:debug": "tap ./bin/cli.spec.test.js -J -R spec",
53
- "test:benchmark": "tap ./benchmark/*.benchmark.test.js --no-timeout --no-coverage",
54
- "test:benchmark:glob": "yarn test:benchmark --grep=\"/input as glob pattern/\"",
55
- "test:benchmark:string": "yarn test:benchmark --grep=\"/input & replacement as strings/\"",
56
- "standard:fix": "standard --fix"
57
- },
58
43
  "devDependencies": {
59
- "perfy": "1.1.5",
60
- "replace": "1.2.1",
44
+ "@vitest/coverage-c8": "^0.31.1",
45
+ "@vitest/ui": "^0.31.1",
46
+ "replace": "1.2.2",
61
47
  "replace-in-file": "6.3.5",
62
48
  "replace-string": "3.1.0",
63
49
  "standard": "17.0.0",
64
50
  "standard-version": "9.5.0",
65
- "tap": "16.3.0",
66
- "tmp-promise": "3.0.3"
51
+ "tmp-promise": "3.0.3",
52
+ "vitest": "^0.31.1"
67
53
  },
68
54
  "dependencies": {
69
55
  "fast-glob": "^3.1.0",
70
56
  "get-stdin": "^8.0.0",
71
57
  "write": "^2.0.0",
72
58
  "yargs": "^17.0.0"
59
+ },
60
+ "scripts": {
61
+ "release": "pnpm lint:fix && pnpm coverage:ci && standard-version && git push --follow-tags origin main && pnpm publish",
62
+ "test:ci": "vitest run",
63
+ "coverage:ci": "vitest run --coverage",
64
+ "test": "vitest",
65
+ "coverage": "vitest --coverage",
66
+ "lint:fix": "pnpm standard --fix",
67
+ "lint:ci": "pnpm standard",
68
+ "test:benchmark": "vitest bench"
73
69
  }
74
- }
70
+ }
package/src/async.js CHANGED
@@ -73,7 +73,7 @@ module.exports = async ({
73
73
  fileStream.on('error', writeError)
74
74
  fileStream.on('data', path => replacePromises.push(new Promise((resolve, reject) =>
75
75
  fs.readFile(path, inputReadOptions, (error, data) => {
76
- /* istanbul ignore next */
76
+ /* c8 ignore next */
77
77
  if (error) return reject(error)
78
78
 
79
79
  resolve([path, replaceFn(data)])
package/CHANGELOG.md DELETED
@@ -1,179 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ## [4.0.0](https://github.com/FRSource/frs-replace/compare/v3.0.3...v4.0.0) (2022-12-07)
6
-
7
-
8
- ### ⚠ BREAKING CHANGES
9
-
10
- * from now on replatement file path should be relative to projects' root
11
-
12
- Signed-off-by: Jakub Freisler <jakub@frsource.org>
13
-
14
- ### Features
15
-
16
- * require replacement method in scope of projects' root ([69fc050](https://github.com/FRSource/frs-replace/commit/69fc05009bf11230fbab73d649b4ce636ebbc8e2))
17
-
18
- ### [3.0.3](https://github.com/FRSource/frs-replace/compare/v3.0.2...v3.0.3) (2021-04-18)
19
-
20
- ### [3.0.2](https://github.com/FRSource/frs-replace/compare/v3.0.1...v3.0.2) (2021-04-18)
21
-
22
-
23
- ### Bug Fixes
24
-
25
- * cli release ([#122](https://github.com/FRSource/frs-replace/issues/122)) ([f813be4](https://github.com/FRSource/frs-replace/commit/f813be403baf49a0c8e8a878e8e4687a73a39832))
26
-
27
- ### [3.0.1](https://github.com/FRSource/frs-replace/compare/v3.0.0...v3.0.1) (2021-01-02)
28
-
29
- ### Bug Fixes
30
-
31
- * security update: ini ([#110](https://github.com/FRSource/frs-replace/pull/110))
32
- * updates: standard ([#107](https://github.com/FRSource/frs-replace/pull/107)), tap ([#106](https://github.com/FRSource/frs-replace/pull/106)), yargs ([#108](https://github.com/FRSource/frs-replace/pull/108)), standard-version ([#111](https://github.com/FRSource/frs-replace/pull/111))
33
-
34
- ## [3.0.0](https://github.com/FRSource/frs-replace/compare/v2.1.2...v3.0.0) (2020-10-27)
35
-
36
-
37
- ### ⚠ BREAKING CHANGES
38
-
39
- * from this version on Node.js api ALWAYS returns an array of replace result array, where replace result array follows the pattern: `[<replaced/new file path>, <replaced content>]`
40
- * renamed `regex` option to `needle`
41
- * renamed `inputJoinString` option to `outputJoinString`
42
-
43
- ### Features
44
-
45
- * different output strategies support ([#100](https://github.com/FRSource/frs-replace/issues/100)) ([d9cabac](https://github.com/FRSource/frs-replace/commit/d9cabac7d220a770637f5ef455e2770b1e28cdd4))
46
-
47
- ### [2.1.2](https://github.com/FRSource/frs-replace/compare/v2.1.1...v2.1.2) (2020-10-14)
48
-
49
- ### Bug Fixes
50
-
51
- * migration to yargs v16 ([yargs changelog](https://github.com/yargs/yargs/blob/master/CHANGELOG.md#1600-2020-09-09))
52
-
53
- ### [2.1.1](https://github.com/FRSource/frs-replace/compare/v2.1.0...v2.1.1) (2020-05-16)
54
-
55
-
56
- ### Bug Fixes
57
-
58
- * cli path for binary command ([2546905](https://github.com/FRSource/frs-replace/commit/254690572e86d31c60aaac5b234fbb6b5d11eabf))
59
-
60
- ## [2.1.0](https://github.com/FRSource/frs-replace/compare/v2.0.1...v2.1.0) (2020-05-15)
61
-
62
-
63
- ### Features
64
-
65
- * change npm package name - add it [@frsource](https://github.com/frsource) scope ([0208a90](https://github.com/FRSource/frs-replace/commit/0208a900c88f29ac167e06524ba583ea62eeb457))
66
- * rename FRS-replace to frs-replace ([#73](https://github.com/FRSource/frs-replace/issues/73)) ([8547685](https://github.com/FRSource/frs-replace/commit/8547685e09e133265ba493b8e5349adf8298b463))
67
-
68
- ### [2.0.1](https://github.com/FRSource/frs-replace/compare/v2.0.0...v2.0.1) (2019-11-01)
69
-
70
- ## [2.0.0](https://github.com/FRSource/frs-replace/compare/v1.0.1...v2.0.0) (2019-10-21)
71
-
72
-
73
- ### ⚠ BREAKING CHANGES
74
-
75
- * **package:** fast-glob does not support backslashes in glob patterns anymore, always use forward-slashes
76
-
77
- ### Features
78
-
79
- * better parallelization ([4d90537](https://github.com/FRSource/frs-replace/commit/4d905375f0550a097d9464b742d13515e1314c94)), closes [#17](https://github.com/FRSource/frs-replace/issues/17) [#10](https://github.com/FRSource/frs-replace/issues/10) [#19](https://github.com/FRSource/frs-replace/issues/19)
80
-
81
-
82
- ### Bug Fixes
83
-
84
- * **package:** update fast-glob to version 3.1.0 ([#44](https://github.com/FRSource/frs-replace/issues/44)) ([735785d](https://github.com/FRSource/frs-replace/commit/735785dfdc99869096cd4c6a3be60fb8f796d54b))
85
- * **package:** update write to version 2.0.0 ([#36](https://github.com/FRSource/frs-replace/issues/36)) ([d0b7ffd](https://github.com/FRSource/frs-replace/commit/d0b7ffdbbd668262860e130551e64b54840ac782))
86
- * **package:** update yargs to version 14.2.0 ([#45](https://github.com/FRSource/frs-replace/issues/45)) ([6df29e4](https://github.com/FRSource/frs-replace/commit/6df29e4e9bda262f9467d85349cd1c61d260c328)), closes [#35](https://github.com/FRSource/frs-replace/issues/35)
87
-
88
- ## [1.0.1](https://github.com/FRSource/frs-replace/compare/v1.0.0...v1.0.1) (2019-10-18)
89
-
90
-
91
- ### Bug Fixes
92
-
93
- * **package:** update yargs to version 13.2.2 ([749b721](https://github.com/FRSource/frs-replace/commit/749b72144049d9c900b04dd2b14473938af963d7)), closes [#20](https://github.com/FRSource/frs-replace/issues/20)
94
-
95
-
96
-
97
- <a name="1.0.0"></a>
98
- # [1.0.0](https://github.com/FRSource/frs-replace/compare/v0.1.2...v1.0.0) (2018-11-14)
99
-
100
-
101
- ### Features
102
-
103
- * **input:** add support for globbing matching ([#14](https://github.com/FRSource/frs-replace/issues/14)) ([b289ffe](https://github.com/FRSource/frs-replace/commit/b289ffe)), closes [#3](https://github.com/FRSource/frs-replace/issues/3)
104
- * **sync:** Sync speed improvements ([#18](https://github.com/FRSource/frs-replace/issues/18)) ([4ff2a1e](https://github.com/FRSource/frs-replace/commit/4ff2a1e)), closes [#17](https://github.com/FRSource/frs-replace/issues/17)
105
-
106
-
107
- ### BREAKING CHANGES
108
-
109
- * **input:** api options rename: 'inputOptions' to 'inputReadOptions', 'outputOptions' to 'outputWriteOptions'
110
- * **input:** cli options rename: 'in-opts' to 'i-read-opts', 'out-opts' to 'o-write-opts'
111
- Add possibility to set input or output options through cli
112
- Docs - fixes & new example
113
- Turn off camel-case-expansion to speed up yargs a bit
114
-
115
-
116
-
117
- <a name="0.1.2"></a>
118
- ## [0.1.2](https://github.com/FRSource/frs-replace/compare/v0.1.1...v0.1.2) (2018-10-19)
119
-
120
-
121
-
122
- <a name="0.1.1"></a>
123
- ## [0.1.1](https://github.com/FRSource/frs-replace/compare/v0.1.0...v0.1.1) (2018-10-17)
124
-
125
-
126
-
127
- <a name="0.1.0"></a>
128
- # [0.1.0](https://github.com/FRSource/frs-replace/compare/v0.0.6...v0.1.0) (2018-10-17)
129
-
130
-
131
- ### Features
132
-
133
- * **cli:** Input & output options ([06e8363](https://github.com/FRSource/frs-replace/commit/06e8363)), closes [#7](https://github.com/FRSource/frs-replace/issues/7)
134
-
135
-
136
-
137
- <a name="0.0.6"></a>
138
- ## [0.0.6](https://github.com/FRSource/frs-replace/compare/v0.0.5...v0.0.6) (2018-10-15)
139
-
140
-
141
- ### Bug Fixes
142
-
143
- * **docs:** positionals table ([7168474](https://github.com/FRSource/frs-replace/commit/7168474)), closes [#6](https://github.com/FRSource/frs-replace/issues/6)
144
-
145
-
146
-
147
- <a name="0.0.5"></a>
148
- ## [0.0.5](https://github.com/FRSource/frs-replace/compare/v0.0.4...v0.0.5) (2018-10-15)
149
-
150
-
151
- ### Bug Fixes
152
-
153
- * **docs:** styling & API usage/examples ([cba85dc](https://github.com/FRSource/frs-replace/commit/cba85dc)), closes [#1](https://github.com/FRSource/frs-replace/issues/1)
154
- * **node:** expose public node API ([c727dff](https://github.com/FRSource/frs-replace/commit/c727dff)), closes [#5](https://github.com/FRSource/frs-replace/issues/5)
155
-
156
-
157
-
158
- <a name="0.0.4"></a>
159
- ## [0.0.4](https://github.com/FRSource/frs-replace/compare/v0.0.3...v0.0.4) (2018-10-15)
160
-
161
-
162
-
163
- <a name="0.0.3"></a>
164
- ## [0.0.3](https://github.com/FRSource/frs-replace/compare/v0.0.2...v0.0.3) (2018-10-15)
165
-
166
-
167
-
168
- <a name="0.0.2"></a>
169
- ## [0.0.2](https://github.com/FRSource/frs-replace/compare/v0.0.1...v0.0.2) (2018-10-15)
170
-
171
-
172
- ### Bug Fixes
173
-
174
- * **npm:** lowercase package name to meet npm requirements ([06daa6a](https://github.com/FRSource/frs-replace/commit/06daa6a))
175
-
176
-
177
-
178
- <a name="0.0.1"></a>
179
- ## 0.0.1 (2018-10-15)