jvcs 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,25 +39,29 @@ function cleanCWD() {
39
39
  }
40
40
  }
41
41
 
42
- function getCommitsToDelete(commitFolder,currentCommit,targetCommit) {
43
-
44
- let toDelete = []
45
-
46
- while(currentCommit && currentCommit !== targetCommit) {
42
+ function buildCommitMap(commitFolder) {
47
43
 
48
- const commitPath = path.join(commitFolder,currentCommit)
49
- const metaPath = path.join(commitPath,"meta.json")
50
-
51
- if(!fs.existsSync(commitPath)) break
52
- toDelete.push(currentCommit)
53
-
54
- let parent = null
44
+ const map = {}
45
+ const dirs = fs.readdirSync(commitFolder)
46
+ for(const dir of dirs) {
47
+ const metaPath = path.join(commitFolder,dir,"meta.json")
55
48
  if(fs.existsSync(metaPath)) {
56
49
  const data = JSON.parse(fs.readFileSync(metaPath,"utf-8"))
57
- parent = data.parent || null
50
+ map[dir] = data.parent
58
51
  }
52
+ }
59
53
 
60
- currentCommit = parent
54
+ return map
55
+ }
56
+
57
+ function getCommitsToDelete(commitFolder,currentCommit,targetCommit) {
58
+
59
+ const commitMap = buildCommitMap(commitFolder)
60
+ const toDelete = []
61
+
62
+ while(currentCommit && currentCommit !== targetCommit) {
63
+ toDelete.push(currentCommit)
64
+ currentCommit = commitMap[currentCommit] || null
61
65
  }
62
66
 
63
67
  return toDelete
@@ -87,7 +91,7 @@ async function deleteCommitsFromDrive(ids) {
87
91
  folderName = `commit_${id}`
88
92
 
89
93
  const res = await drive.files.list({
90
- q: `name=${folderName} and trashed=false`,
94
+ q: `name='${folderName}' and trashed=false`,
91
95
  fields: "files(id,name)"
92
96
  })
93
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "bin": {
5
5
  "jvcs": "./index.js"
6
6
  },