Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated unlimited resources for 0.17, changed helper scripts to types…
…cript
- Loading branch information
1 parent
a2aa482
commit e5536fa
Showing
7 changed files
with
199 additions
and
63 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as path from "path"; | ||
import * as util from "util"; | ||
import * as fs from "fs-extra"; | ||
import * as archiver from "archiver"; | ||
|
||
const OUTPUT_DIR = path.join(__dirname, "build"); | ||
|
||
async function main() { | ||
if (!process.argv[2]) { | ||
return console.log("Please supply a directory name as argument"); | ||
} | ||
|
||
const mod = path.join(__dirname, process.argv[2]); | ||
|
||
fs.stat(mod, (err, x) => { | ||
if (err) return console.log(`The directory ${mod} does not exist`); | ||
if (!x.isDirectory()) return console.log(`${mod} is not a directory`); | ||
|
||
build(mod); | ||
}); | ||
} | ||
|
||
async function build(mod_name: string) { | ||
console.log(`Building ${mod_name}`); | ||
|
||
const info = await fs.readJSON(path.join(mod_name, "info.json")); | ||
const filename = `${info.name}_${info.version}`; | ||
|
||
await zip(mod_name, filename); | ||
} | ||
|
||
async function zip(mod_name: string, filename: string) { | ||
return new Promise(async (resolve, reject) => { | ||
console.log(`Zipping ${mod_name}...`); | ||
|
||
await fs.ensureDir(OUTPUT_DIR); | ||
|
||
const output_path = path.resolve(OUTPUT_DIR, `${filename}.zip`); | ||
const output = fs.createWriteStream(output_path); | ||
|
||
const archive = archiver("zip", { | ||
zlib: { level: 9 } | ||
}); | ||
|
||
archive.directory(mod_name, filename); | ||
|
||
output.on("close", () => { | ||
console.log(`Done: ${output_path} [${Math.round(archive.pointer() / 102.4) / 10}kb]`); | ||
}); | ||
|
||
archive.pipe(output); | ||
archive.finalize(); | ||
}); | ||
} | ||
|
||
main().catch(console.error); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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