Skip to content

Commit

Permalink
fix: store prompts matched fail when from git
Browse files Browse the repository at this point in the history
  • Loading branch information
imcuttle committed May 18, 2018
1 parent 0f81644 commit ff2e4e7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/edam/src/core/storePrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ async function _get(cacheDir: string) {
)
}
}
async function _store(cacheDir: string, source, promptValues) {
const filename = getFilename(cacheDir)
const old = await _get(cacheDir)

let key = ''
function getKeyBySource(source: Source) {
let key
switch (source.type) {
case 'git':
key = source.url + '?checkout=' + source.checkout
Expand All @@ -54,6 +52,13 @@ async function _store(cacheDir: string, source, promptValues) {
default:
key = source.url
}
return key
}

async function _store(cacheDir: string, source, promptValues) {
const filename = getFilename(cacheDir)
const old = await _get(cacheDir)
let key = getKeyBySource(source)
old[key] = promptValues
await fileSystem.writeFile(filename, JSON.stringify(old))
}
Expand Down Expand Up @@ -99,7 +104,7 @@ export async function get({
if (!cacheDir) {
return
}
let old = (await _get(<string>cacheDir))[source.url]
let old = (await _get(<string>cacheDir))[getKeyBySource(source)]
old = { ...old }
const deniesStoreNames = prompts.filter(x => !!x.deniesStore).map(x => x.name)
deniesStoreNames.forEach(name => {
Expand Down

0 comments on commit ff2e4e7

Please sign in to comment.