Skip to content

Commit

Permalink
fixed self copy bug (#8)
Browse files Browse the repository at this point in the history
* fixed self copy bug

* bump version
  • Loading branch information
hoonsubin authored Nov 1, 2020
1 parent 5f66a9d commit 9ec25b4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glitch-deploy-tool",
"version": "0.1.2-alpha",
"version": "0.1.3-alpha",
"description": "CLI tool for deploying files to Glitch.com",
"keywords": [
"glitch.com",
Expand Down
9 changes: 7 additions & 2 deletions src/cli/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { GlitchGit, GlitchProject } from '../models';
export const importFromFolder = async (repoUrl: string, targetPath?: string, debugMessage?: boolean) => {
const glitchRepo = new GlitchGit(repoUrl, debugMessage);

await glitchRepo.publishFilesToGlitch(targetPath);
try {
await glitchRepo.publishFilesToGlitch(targetPath);
} catch (e) {
glitchRepo.cleanGitInstance();
throw e;
}

console.log('successfully imported projects from ' + targetPath);
console.log('successfully imported projects from ' + targetPath || process.cwd());
};

export const importFromGithub = async (token: string, projId: string, repo: string, path?: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ const checkToolMode = () => {

// print the tool version
if (opts.version) {
//todo: dynamically parse the version
console.log(`glitch-deploy-tool version 0.1.1-alpha`);
//todo: dynamically parse the app version without importing package.json (due to tsc folder structure)
console.log(`glitch-deploy-tool version 0.1.3-alpha`);
process.exit(0);
}

Expand Down
14 changes: 9 additions & 5 deletions src/models/glitchGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ export default class GlitchRepo {
await this._pushChangesToRemote();

this._writeLog('cleaning up...');
this._cleanGitInstance();
// remove the local repo
rimraf.sync(this._glitchRepoDir);
this.cleanGitInstance();

this._writeLog('done');
}

private _cleanGitInstance() {
public cleanGitInstance() {
if (!this._glitchRepoDir) {
throw new Error('Glitch project is not cloned to the local machine yet');
}

this._gitInst = this._gitInst.clearQueue();
// remove the local repo
rimraf.sync(this._glitchRepoDir);
}

private async _cloneRepo() {
Expand Down Expand Up @@ -106,7 +110,7 @@ export default class GlitchRepo {

this._writeLog(`cloning everything inside ${folderToCopy} to Glitch`);
// move the new contents to Glitch
Helpers.copyFolderContent(folderToCopy, this._glitchRepoDir, ['.git']);
Helpers.copyFolderContent(folderToCopy, this._glitchRepoDir, ['.git', REPO_FOLDER]);
}

private async _pushChangesToRemote() {
Expand Down

0 comments on commit 9ec25b4

Please sign in to comment.