@vacantthinker/firefox-addon-framework-easy-nodejs 2026.5.2201 → 2026.5.2203

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/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy-nodejs",
3
- "version": "2026.5.2201",
3
+ "version": "2026.5.2203",
4
4
  "description": "",
5
5
  "main": "index.js",
6
- "type": "module",
7
6
  "publishConfig": {
8
7
  "access": "public"
9
8
  },
10
9
  "scripts": {
11
- "git_acp": "git add . && git commit -m 'add toolzipfileordirs.js' && git push",
10
+ "git_acp": "git add . && git commit -m 'update __dirname to process.cwd()' && git push",
12
11
  "npm_publish": "npm publish"
13
12
  },
14
13
  "dependencies": {
@@ -23,62 +23,70 @@
23
23
  * suffix: [string]
24
24
  * }|null}
25
25
  */
26
+
27
+ import {createRequire} from 'module';
28
+ import path from 'path';
29
+
26
30
  export function zipFilesOrDirectorys(
27
31
  outputAppendName,
28
32
  oneDirecoty = null,
29
33
  ignoreObj = null) {
30
34
 
31
- const archiver = require('archiver')
32
- const fs = require('fs')
33
- const path = require('path')
34
- const basename = path.basename(__dirname)
35
+ const require = createRequire(import.meta.url);
36
+ const fs = require('fs');
37
+ const archiver = require('archiver');
35
38
 
36
- const arrFilename = Array.from([basename])
39
+ // FIX: Use the execution root directory instead of the package directory
40
+ const projectRootDir = process.cwd();
41
+ const basename = path.basename(projectRootDir);
42
+
43
+ const arrFilename = Array.from([basename]);
37
44
  if (outputAppendName) {
38
- arrFilename.push(outputAppendName)
45
+ arrFilename.push(outputAppendName);
39
46
  }
40
- const output = fs.createWriteStream(path.join(__dirname, `${arrFilename.join('-')}.zip`))
41
- const archive = archiver('zip')
47
+
48
+ // Output the zip directly into your project root directory
49
+ const output = fs.createWriteStream(path.join(projectRootDir, `${arrFilename.join('-')}.zip`));
50
+ const archive = archiver('zip');
51
+
42
52
  output.on('close', () => {
43
- console.info(`${outputAppendName} zip finish!`)
44
- })
53
+ console.info(`${outputAppendName} zip finish!`);
54
+ });
45
55
  archive.on('error', (e) => {
46
- console.info('e=');
47
- console.info(e);
48
- })
56
+ console.info('e=', e);
57
+ });
49
58
 
50
- archive.pipe(output)
59
+ archive.pipe(output);
51
60
 
52
61
  if (oneDirecoty) {
53
- // todo one dir
54
- archive.directory(`${oneDirecoty}/`, false)
62
+ archive.directory(`${oneDirecoty}/`, false);
55
63
  } else if (ignoreObj) {
56
- let strings = fs.readdirSync(__dirname);
64
+ // Scan the project root directory, not node_modules
65
+ let strings = fs.readdirSync(projectRootDir);
57
66
 
58
- let {exclude, suffix} = ignoreObj
67
+ let {exclude, suffix} = ignoreObj;
59
68
  let arrFilter = strings
60
69
  .filter(name => !exclude.includes(name))
61
- .filter(name => !suffix.some(value => name.endsWith(value)))
62
- console.info('arrFilter=');
63
- console.info(arrFilter);
70
+ .filter(name => !suffix.some(value => name.endsWith(value)));
71
+
72
+ console.info('arrFilter=', arrFilter);
64
73
 
65
74
  arrFilter.forEach(filename => {
66
- let pathFile = path.join(__dirname, filename);
75
+ let pathFile = path.join(projectRootDir, filename);
67
76
  let stats = fs.lstatSync(pathFile);
68
77
  if (stats.isDirectory()) {
69
- archive.directory(`${filename}/`)
78
+ archive.directory(pathFile, filename);
70
79
  } else if (stats.isFile()) {
71
- archive.file(pathFile, {name: filename})
80
+ archive.file(pathFile, {name: filename});
72
81
  }
73
- })
74
- } else {
75
-
82
+ });
76
83
  }
77
84
 
78
85
  archive.finalize();
79
- console.info(`${outputAppendName} zip starting`)
86
+ console.info(`${outputAppendName} zip starting`);
80
87
  }
81
88
 
89
+
82
90
  /**
83
91
  * zipFilesOrDirectorys(null, 'dist');
84
92
  *