@markuplint/i18n 4.0.0-alpha.5 → 4.0.0-dev.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.
Files changed (2) hide show
  1. package/esm.mjs +42 -0
  2. package/package.json +3 -5
package/esm.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ /**
5
+ *
6
+ * @param {string} filePath
7
+ * @param {string} newExtension
8
+ */
9
+ function renameFileExtension(filePath, newExtension) {
10
+ const dir = path.dirname(filePath);
11
+ const fileName = path.basename(filePath, path.extname(filePath)) + newExtension;
12
+ const newFilePath = path.join(dir, fileName);
13
+ fs.renameSync(filePath, newFilePath);
14
+ return newFilePath;
15
+ }
16
+
17
+ function replaceInFile(filePath, searchValue, replaceValue) {
18
+ const data = fs.readFileSync(filePath, 'utf8');
19
+ const result = data.replace(searchValue, replaceValue);
20
+ fs.writeFileSync(filePath, result, 'utf8');
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param {string} dir
26
+ */
27
+ function processDirectory(dir) {
28
+ const files = fs.readdirSync(dir, { withFileTypes: true });
29
+ for (const file of files) {
30
+ const fullPath = path.join(dir, file.name);
31
+ if (file.isDirectory()) {
32
+ processDirectory(fullPath);
33
+ } else {
34
+ if (file.name.endsWith('.js')) {
35
+ const newFilePath = renameFileExtension(fullPath, '.mjs');
36
+ replaceInFile(newFilePath, /\.js/g, '.mjs');
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ processDirectory('./esm');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/i18n",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-dev.0+7c596917",
4
4
  "description": "Internationalization for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -32,12 +32,10 @@
32
32
  "entryPoint": "./src/index.ts"
33
33
  },
34
34
  "scripts": {
35
- "build": "yarn build:esm; yarn build:cjs; yarn rename:esm; yarn replaceext:esm",
35
+ "build": "yarn build:esm; yarn build:cjs; node ./esm.mjs",
36
36
  "build:esm": "tsc",
37
37
  "build:cjs": "tsc --module commonjs --outDir cjs",
38
- "rename:esm": "find ./esm -type f -name \"*.js\" -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
39
- "replaceext:esm": "find ./esm -type f -name \"*.mjs\" -exec sed -i '' 's/\\.js/\\.mjs/g' {} \\;",
40
38
  "clean": "tsc --build --clean"
41
39
  },
42
- "gitHead": "0c3e4690662edf1765bcc4b6411ec5507c1e2ea3"
40
+ "gitHead": "7c59691701465a0fb3a4b69187318e8033c463d4"
43
41
  }