rokojori-godot/create-output.js

100 lines
2.2 KiB
JavaScript
Raw Normal View History

2024-04-27 15:03:50 +00:00
const { argv } = require("process");
const path = require( "path" );
const fs = require( "node:fs/promises" );
const { exists } = require( "./library.js" );
if ( argv.length !== 3 )
{
let platforms = [ "windows" ];
console.error( "Platform missing in the command. Add one of these to the command line:", platforms.join( ", " ) );
return;
}
let targetDirectory = "outputs";
let godotName = "godot-4.3-dev-rokojori";
let platform = argv[ 2 ];
let godotPlatformName = godotName + "-" + argv[ 2 ];
let platformTargetDirectory = path.join( targetDirectory, godotPlatformName );
async function main()
{
console.log( "Creating output" );
await deleteOldDirectory();
await createDirectory();
console.log( "Output done" );
}
async function deleteOldDirectory()
{
let directoryExists = await exists( platformTargetDirectory );
console.log( "checking if old directory exists", directoryExists );
if ( directoryExists )
{
console.log( `deleting previous directory: "${platformTargetDirectory}"` );
await fs.rm( platformTargetDirectory, { recursive: true } );
}
return Promise.resolve();
}
async function createDirectory()
{
console.log( `creating directory: "${platformTargetDirectory}"` );
await fs.mkdir( platformTargetDirectory, { recursive: true } );
let godotFrom = "godot/bin";
let godotTo = path.join( platformTargetDirectory, "godot" );
console.log( `copying godot: "${godotFrom}" >> "${godotTo}"` );
await fs.cp( godotFrom, godotTo, { recursive : true } );
let npFrom = "godot-rj-nuget-package";
let npTo = path.join( platformTargetDirectory, npFrom );
console.log( `copying nupkg: "${npFrom}" >> "${npTo}"` );
await fs.cp( npFrom, npTo, { recursive : true } );
2024-05-04 08:03:10 +00:00
let installerFiles =
2024-04-27 15:03:50 +00:00
{
2024-05-04 08:03:10 +00:00
"windows" :
[
"install-godot-windows.bat",
"install-godot-windows-readme.txt"
]
2024-04-27 15:03:50 +00:00
};
2024-05-04 08:03:10 +00:00
let installers = installerFiles[ platform ];
2024-04-27 15:03:50 +00:00
2024-05-04 08:03:10 +00:00
for ( let installer of installers )
{
let installFrom = "install-scripts/" + installer;
2024-04-27 15:03:50 +00:00
2024-05-04 08:03:10 +00:00
let installTo = path.join( platformTargetDirectory, installer );
console.log( `copying installer: "${installFrom}" >> "${installTo}"` );
await fs.cp( installFrom, installTo, { recursive : true } );
}
2024-04-27 15:03:50 +00:00
}
main();