Skip to content

Commit

Permalink
Merge pull request #18 from bscotch/feature/clear-remote-cache
Browse files Browse the repository at this point in the history
feat: added the CLI command to use Igor to clear remote client
  • Loading branch information
paperclover authored Nov 22, 2018
2 parents 1e507a5 + cce69a8 commit d1f1ef0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/tasks.json
/settings.json
27 changes: 16 additions & 11 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const options = cli.parse({
config: ["c", "Sets the configuration", "string"],
version: ["v", "Display the current version"],
clear: ["", "Clears cache for project and exits."],
"clear_remote": ["","Clears the remote client cache."],
"gms-dir":["","Alternative GMS installation directory","path"],
"export-platform":["p","Export platform","string"],
"device-config-dir":["","Target device config file directory", "path"],
Expand Down Expand Up @@ -79,14 +80,6 @@ cli.main(async (args, options) => {
cli.fatal("Project invalid, or in a newer format. Exiting");
}

// Clear cache option
if(options.clear) {
rubber.clearCache(path).then(() => {
cli.info("Cleared Project Cache.");
});
return;
}

// We have a probably valid project. Time to pass it to rubber
let buildType: "test" | "zip" | "installer" = "test";
if (options.zip && options.installer) {
Expand Down Expand Up @@ -127,8 +120,8 @@ cli.main(async (args, options) => {
theRuntime = options["runtime"];
}

// Use the api to compile the project.
const build = rubber.compile({
//
let rubberOptions = {
projectPath: path,
build: buildType,
outputPath: args[1] || "",
Expand All @@ -141,7 +134,19 @@ cli.main(async (args, options) => {
targetDeviceName,
theRuntime,
ea: options.ea
});
}

// Clear build machine's cache
if(options.clear) {
rubber.clearCache(path).then(() => {
cli.info("Cleared Project Cache.");
});
return;
}

// Use the api to compile the project or clear the remote client cache.
const build = options["clear_remote"] ? rubber.clearCacheRemote(rubberOptions) : rubber.compile(rubberOptions,false);

build.on("compileStatus", (data:string) => {
// Errors will be marked in red
if(data.toLowerCase().startsWith("error")) {
Expand Down
9 changes: 7 additions & 2 deletions src/rubber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface IRubberOptions {
* @param projectFile Path to the .yyp project
* @param options Object containing build information.
*/
export function compile(options: IRubberOptions) {
export function compile(options: IRubberOptions, clearRemoteCache: boolean = false) {
const emitter = new EventEmitter() as RubberEventEmitter; // we dont need the overhead of a sub class
const projectFile = resolve(options.projectPath);
const platform = options.platform;
Expand Down Expand Up @@ -506,7 +506,7 @@ export function compile(options: IRubberOptions) {

emitter.emit("compileStatus", "Running IGOR\n");
const exportType = options.build == "test" ? "Run" : (options.build === "zip" ? defaultPackageKey : "PackageNsis")
const igorArgs = ["-options=" + join(buildTempPath, "build.bff"), "--", component, exportType];
const igorArgs = ["-options=" + join(buildTempPath, "build.bff"), "--", component, clearRemoteCache ? "Clean" : exportType];
const igor = spawn(join(runtimeLocation, "bin", "Igor.exe"), igorArgs);

// !!! #8 todo: store errors here, emit at end.
Expand Down Expand Up @@ -586,3 +586,8 @@ export async function clearCache(projectPath: string) {
// delete the folder
await fse.remove(join(tempFolder, "gamemaker-rubber", guid));
}

/** Use Igor's Clean function to clear remote client's cache */
export function clearCacheRemote(options: IRubberOptions){
return compile(options, true);
}

0 comments on commit d1f1ef0

Please sign in to comment.