Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
create standalone.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ffrostfall committed Jul 16, 2023
1 parent 73384e2 commit 35e1220
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions standalone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const {
mkdirSync,
writeFileSync
} = require("fs");
const { copySync } = require("fs-extra");
const { join, dirname, basename } = require("path");
const { execFile } = require("child_process");
const { rimraf } = require("rimraf");

async function buildStandalone() {
return new Promise((resolve) => {
const projectName = basename(dirname(__filename));

const srcDir = join(projectName, "../src");
const packageDir = join(projectName, "../Packages");
const destinationDir = join(projectName, "../standalone");
const destSrcDir = join(destinationDir, "./src");
const standaloneProject = join(projectName, "../standalone.project.json");

mkdirSync(destinationDir);
mkdirSync(destSrcDir);
writeFileSync(
join(destinationDir, "./init.luau"),
"return require(script.src)"
);
writeFileSync(
standaloneProject,
`{"name": "${projectName}","tree": {"$path" : "standalone"}}`
);

copySync(packageDir, destinationDir);
copySync(srcDir, destSrcDir);

execFile(
"rojo",
["build", "-o=standalone.rbxm", "standalone.project.json"],
() => {
rimraf(destinationDir)
.catch((err) => {
console.log(err);
})
.then(() => {
rimraf(standaloneProject);
resolve();
});
}
);
});
}

buildStandalone()

0 comments on commit 35e1220

Please sign in to comment.