@frsource/frs-replace 3.0.2 → 4.0.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
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
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
+
5
20
  ### [3.0.2](https://github.com/FRSource/frs-replace/compare/v3.0.1...v3.0.2) (2021-04-18)
6
21
 
7
22
 
package/async.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./src/sync')
package/bin/cli.js CHANGED
@@ -125,7 +125,7 @@ require('get-stdin')().then((stdin) => {
125
125
  outputWriteOptions: argv['o-write-opts'],
126
126
  outputJoinString: argv['o-join-str'],
127
127
  needle: new RegExp(argv.needle, argv.f),
128
- replacement: argv.r ? require(argv.replacement) : argv.replacement
128
+ replacement: argv.r ? require(require('path').resolve(argv.replacement)) : argv.replacement
129
129
  })
130
130
 
131
131
  if (argv.stdout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frsource/frs-replace",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "description": "Simple wrapper around javascript replace with CLI usage support!",
5
5
  "bin": {
6
6
  "frs-replace": "./bin/cli.js"
@@ -18,6 +18,8 @@
18
18
  "src/sync.js",
19
19
  "src/async.js",
20
20
  "src/utils.js",
21
+ "sync.js",
22
+ "async.js",
21
23
  "index.js",
22
24
  "LICENSE",
23
25
  "package.json",
@@ -39,7 +41,7 @@
39
41
  "javascript"
40
42
  ],
41
43
  "scripts": {
42
- "prerelease": "yarn standard:fix && yarn test && yarn test:benchmark",
44
+ "prerelease": "yarn standard:fix && yarn test",
43
45
  "release": "standard-version",
44
46
  "postrelease": "git push --follow-tags origin master && yarn publish",
45
47
  "pretest": "standard",
@@ -54,19 +56,19 @@
54
56
  "standard:fix": "standard --fix"
55
57
  },
56
58
  "devDependencies": {
57
- "perfy": "^1.1.5",
58
- "replace": "^1.2.0",
59
- "replace-in-file": "^6.0.0",
60
- "replace-string": "^3.1.0",
61
- "standard": "^16.0.0",
62
- "standard-version": "^9.0.0",
63
- "tap": "^14.10.7",
64
- "tmp-promise": "^3.0.2"
59
+ "perfy": "1.1.5",
60
+ "replace": "1.2.1",
61
+ "replace-in-file": "6.3.5",
62
+ "replace-string": "3.1.0",
63
+ "standard": "17.0.0",
64
+ "standard-version": "9.5.0",
65
+ "tap": "16.3.0",
66
+ "tmp-promise": "3.0.3"
65
67
  },
66
68
  "dependencies": {
67
69
  "fast-glob": "^3.1.0",
68
70
  "get-stdin": "^8.0.0",
69
71
  "write": "^2.0.0",
70
- "yargs": "^16.0.3"
72
+ "yargs": "^17.0.0"
71
73
  }
72
74
  }
package/src/utils.js CHANGED
@@ -3,20 +3,20 @@ const writeError = msg => { throw new Error(`@frsource/frs-replace :: ${msg}`) }
3
3
  const getReplaceFn = (needle, replacement) =>
4
4
  typeof needle === 'string'
5
5
  ? content => {
6
- const needleLen = needle.length
7
- let result = ''
8
- let i
9
- let endIndex = 0
6
+ const needleLen = needle.length
7
+ let result = ''
8
+ let i
9
+ let endIndex = 0
10
10
 
11
- while ((i = content.indexOf(needle, endIndex)) !== -1) {
12
- result += content.slice(endIndex, i) + replacement
13
- endIndex = i + needleLen
14
- }
11
+ while ((i = content.indexOf(needle, endIndex)) !== -1) {
12
+ result += content.slice(endIndex, i) + replacement
13
+ endIndex = i + needleLen
14
+ }
15
15
 
16
- result += content.slice(endIndex, content.length)
16
+ result += content.slice(endIndex, content.length)
17
17
 
18
- return result
19
- }
18
+ return result
19
+ }
20
20
  : content => content.replace(needle, replacement)
21
21
 
22
22
  module.exports = { writeError, getReplaceFn }
package/sync.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./src/sync')