Skip to content

Commit 2183755

Browse files
committedJul 15, 2020
target user folder with remove file
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent 4641fdb commit 2183755

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed
 

‎src/channel/index.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { openWorkspace, checkWorkspaceEmpty } from '../services/workspace'
1818
import { showOutput } from '../services/testRunner/output'
1919
import { exec } from '../services/node'
2020
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'
21-
import reset from '../services/git/reset'
22-
import getLastCommitHash from '../services/git/lastHash'
21+
import reset from '../services/reset'
22+
import getLastCommitHash from '../services/reset/lastHash'
2323

2424
const readFileAsync = promisify(readFile)
2525

@@ -330,8 +330,15 @@ class Channel implements Channel {
330330
// get last pass commit
331331
const hash = getLastCommitHash(position, tutorial?.levels || [])
332332

333+
const branch = tutorial?.config.repo.branch
334+
335+
if (!branch) {
336+
console.error('No repo branch found for tutorial')
337+
return
338+
}
339+
333340
// load timeline until last pass commit
334-
reset({ branch: tutorial?.config.repo.branch, hash })
341+
reset({ branch, hash })
335342

336343
// if tutorial.config.reset.command, run it
337344
if (tutorial?.config?.reset?.command) {

‎src/services/node/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { promisify } from 'util'
55
import { WORKSPACE_ROOT } from '../../environment'
66

77
const asyncExec = promisify(cpExec)
8+
const asyncRemoveFile = promisify(fs.unlink)
89

910
interface ExecParams {
1011
command: string
@@ -19,3 +20,7 @@ export const exec = (params: ExecParams): Promise<{ stdout: string; stderr: stri
1920
export const exists = (...paths: string[]): boolean | never => {
2021
return fs.existsSync(join(WORKSPACE_ROOT, ...paths))
2122
}
23+
24+
export const removeFile = (...paths: string[]) => {
25+
return asyncRemoveFile(join(WORKSPACE_ROOT, ...paths))
26+
}

‎src/services/git/reset.ts ‎src/services/reset/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import * as fs from 'fs'
2-
import { promisify } from 'util'
3-
import { exec } from '../node'
4-
5-
const removeFile = promisify(fs.unlink)
1+
import { exec, removeFile } from '../node'
62

73
interface Input {
84
hash: string
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)
Failed to load comments.