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

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.2202",
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 'convert to es module' && git push",
12
11
  "npm_publish": "npm publish"
13
12
  },
14
13
  "dependencies": {
@@ -1,3 +1,12 @@
1
+ import archiver from 'archiver';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ // Fix for __dirname in ES Modules
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
1
10
  /**
2
11
  *
3
12
  * // zip dist dir => output: current-project-name.zip
@@ -28,57 +37,50 @@ export function zipFilesOrDirectorys(
28
37
  oneDirecoty = null,
29
38
  ignoreObj = null) {
30
39
 
31
- const archiver = require('archiver')
32
- const fs = require('fs')
33
- const path = require('path')
34
40
  const basename = path.basename(__dirname)
35
-
36
41
  const arrFilename = Array.from([basename])
42
+
37
43
  if (outputAppendName) {
38
44
  arrFilename.push(outputAppendName)
39
45
  }
46
+
40
47
  const output = fs.createWriteStream(path.join(__dirname, `${arrFilename.join('-')}.zip`))
41
48
  const archive = archiver('zip')
49
+
42
50
  output.on('close', () => {
43
51
  console.info(`${outputAppendName} zip finish!`)
44
52
  })
45
53
  archive.on('error', (e) => {
46
- console.info('e=');
47
- console.info(e);
54
+ console.info('e=', e);
48
55
  })
49
56
 
50
57
  archive.pipe(output)
51
58
 
52
59
  if (oneDirecoty) {
53
- // todo one dir
54
60
  archive.directory(`${oneDirecoty}/`, false)
55
61
  } else if (ignoreObj) {
56
62
  let strings = fs.readdirSync(__dirname);
57
-
58
63
  let {exclude, suffix} = ignoreObj
59
64
  let arrFilter = strings
60
65
  .filter(name => !exclude.includes(name))
61
66
  .filter(name => !suffix.some(value => name.endsWith(value)))
62
- console.info('arrFilter=');
63
- console.info(arrFilter);
64
67
 
65
68
  arrFilter.forEach(filename => {
66
69
  let pathFile = path.join(__dirname, filename);
67
70
  let stats = fs.lstatSync(pathFile);
68
71
  if (stats.isDirectory()) {
69
- archive.directory(`${filename}/`)
72
+ archive.directory(pathFile, filename) // Fixed pathing issue
70
73
  } else if (stats.isFile()) {
71
74
  archive.file(pathFile, {name: filename})
72
75
  }
73
76
  })
74
- } else {
75
-
76
77
  }
77
78
 
78
79
  archive.finalize();
79
80
  console.info(`${outputAppendName} zip starting`)
80
81
  }
81
82
 
83
+
82
84
  /**
83
85
  * zipFilesOrDirectorys(null, 'dist');
84
86
  *