Skip to content

Commit 8323386

Browse files
committed
Remove source comments from installable packages.
1 parent 41eea27 commit 8323386

3 files changed

Lines changed: 82 additions & 4 deletions

File tree

COPYRIGHT

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
NoScript - a Firefox extension for whitelist driven safe JavaScript execution
2+
3+
Copyright (C) 2005-2026 Giorgio Maone <https://maone.net>
4+
5+
SPDX-License-Identifier: GPL-3.0-or-later
6+
7+
This program is free software: you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License as published by the Free Software
9+
Foundation, either version 3 of the License, or (at your option) any later
10+
version.
11+
12+
This program is distributed in the hope that it will be useful, but WITHOUT
13+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License along with
17+
this program. If not, see <https://www.gnu.org/licenses/>.

build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ XPI="$XPI_DIR/noscript-${VER}"
135135

136136
rm -rf "$BUILD" "$XPI"
137137
cp -pR "$SRC" "$BUILD"
138-
cp -p LICENSE "$BUILD"/
138+
cp -p LICENSE COPYRIGHT "$BUILD"/
139139

140140
BUILD_CMD="web-ext"
141141
BUILD_OPTS="build --overwrite-dest"
@@ -224,12 +224,14 @@ build() {
224224
if [[ $UNPACKED_ONLY ]]; then
225225
return
226226
fi
227-
227+
WEBEXT_IN="${UNPACKED_DIR}_pkg"
228+
rm -rf "$WEBEXT_IN"
229+
cp -rp "$UNPACKED_DIR" "$WEBEXT_IN"
230+
node optimize.js "$WEBEXT_IN"
228231
if [ "$CYGPATH" ]; then
229-
WEBEXT_IN="$(cygpath -w "$UNPACKED_DIR")"
232+
WEBEXT_IN="$(cygpath -w "$WEBEXT_IN")"
230233
WEBEXT_OUT="$(cygpath -w "$XPI_DIR")"
231234
else
232-
WEBEXT_IN="$UNPACKED_DIR"
233235
WEBEXT_OUT="$XPI_DIR"
234236
fi
235237

optimize.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* NoScript - a Firefox extension for whitelist driven safe JavaScript execution
3+
*
4+
* Copyright (C) 2005-2026 Giorgio Maone <https://maone.net>
5+
*
6+
* SPDX-License-Identifier: GPL-3.0-or-later
7+
*
8+
* This program is free software: you can redistribute it and/or modify it under
9+
* the terms of the GNU General Public License as published by the Free Software
10+
* Foundation, either version 3 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* This program is distributed in the hope that it will be useful, but WITHOUT
14+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License along with
18+
* this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
const fs = require('fs');
22+
const path = require('path');
23+
24+
const decomment = require('decomment');
25+
26+
const dir = process.argv[2];
27+
28+
if (!dir) {
29+
console.error('Please provide a directory path!');
30+
process.exit(1);
31+
}
32+
33+
function processSource(s) {
34+
return decomment(
35+
s, { space: true, tolerant: true }
36+
);
37+
}
38+
39+
function processDir(dir) {
40+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
41+
const { name } = entry;
42+
const entryPath = path.join(dir, name);
43+
if (entry.isDirectory()) {
44+
processDir(entryPath);
45+
} else if (entry.isFile() && path.extname(name) == ".js") {
46+
try {
47+
console.log(`Processing ${entryPath}...`);
48+
fs.writeFileSync(entryPath, processSource(
49+
fs.readFileSync(entryPath, 'utf8')
50+
));
51+
console.log(`Done processing ${entryPath}...`);
52+
} catch (err) {
53+
console.error(`Error processing ${entryPath}:`, err.message);
54+
}
55+
}
56+
}
57+
}
58+
59+
processDir(dir);

0 commit comments

Comments
 (0)