-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
const pathUtil = require('path'); | ||
const fs = require('fs'); | ||
const zlib = require('zlib'); | ||
const Builder = require('@turbowarp/extensions/builder'); | ||
|
||
const outputDirectory = pathUtil.join(__dirname, '../dist-extensions/'); | ||
const mode = 'desktop'; | ||
const builder = new Builder(mode); | ||
const build = builder.build(); | ||
build.export(outputDirectory); | ||
console.log(`Built extensions (mode: ${mode})`); | ||
|
||
const outputDirectory = pathUtil.join(__dirname, '../dist-extensions/'); | ||
fs.rmSync(outputDirectory, { | ||
recursive: true, | ||
force: true, | ||
}); | ||
for (const [relativePath, file] of Object.entries(build.files)) { | ||
console.log(`Compressing ${relativePath}`); | ||
const directoryName = pathUtil.dirname(relativePath); | ||
fs.mkdirSync(pathUtil.join(outputDirectory, directoryName), { | ||
recursive: true, | ||
}); | ||
const contents = file.read(); | ||
const compressed = zlib.brotliCompressSync(contents); | ||
fs.writeFileSync(pathUtil.join(outputDirectory, `${relativePath}.br`), compressed); | ||
} | ||
|
||
console.log(`Built ${mode} copy of extensions.turbowarp.org to ${outputDirectory}`); | ||
console.log(`Exported to ${outputDirectory}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters