Skip to content

Commit 4f97a3e

Browse files
committed
Deleted old cachePaths
1 parent 81f1ba9 commit 4f97a3e

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

utils/bump/chatbots.mjs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,29 @@ const script = {
2626
const cache = { paths: { root: '.cache' }}
2727
cache.paths.bumpmjs = path.join(process.cwd(), `${cache.paths.root}/bump.min.mjs`)
2828
cache.paths.chatbots = path.join(process.cwd(), `${cache.paths.root}/chatbots.json`)
29-
const { cache: { paths: cachePaths }} = script
3029
const gitCmd = process.platform == 'win32' ? 'git' : '/usr/bin/git' // same as your ext script
3130

3231
// Import bump.mjs
33-
fs.mkdirSync(path.dirname(cachePaths.bumpmjs), { recursive: true })
34-
fs.writeFileSync(cachePaths.bumpmjs, (await (await fetch(script.urls.bumpmjs)).text()))
35-
const bump = await import(`file://${cachePaths.bumpmjs}`),
32+
fs.mkdirSync(path.dirname(cache.paths.bumpmjs), { recursive: true })
33+
fs.writeFileSync(cache.paths.bumpmjs, (await (await fetch(script.urls.bumpmjs)).text()))
34+
const bump = await import(`file://${cache.paths.bumpmjs}`),
3635
{ bumpVersion, colors: { ansi }, findFileBySuffix, initKudoSyncBot, log } = bump
37-
fs.unlinkSync(cachePaths.bumpmjs)
36+
fs.unlinkSync(cache.paths.bumpmjs)
3837

3938
log.working(`\n${script.config.cache ? 'Collecting' : 'Searching for'} chatbot userscripts...\n`)
4039
let chatbotFiles = []
4140
if (script.config.cache) {
4241
try { // create missing cache file
43-
fs.mkdirSync(path.dirname(cachePaths.chatbots), { recursive: true })
44-
const fd = fs.openSync(cachePaths.chatbots,
42+
fs.mkdirSync(path.dirname(cache.paths.chatbots), { recursive: true })
43+
const fd = fs.openSync(cache.paths.chatbots,
4544
fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_RDWR)
46-
log.info(`Cache file missing. Generating ${cachePaths.chatbots}...\n`)
45+
log.info(`Cache file missing. Generating ${cache.paths.chatbots}...\n`)
4746
for (const chatbot of script.chatbots)
4847
chatbotFiles.push(...(await findFileBySuffix({ suffix: `${chatbot}.user.js` })))
4948
fs.writeFileSync(fd, JSON.stringify(chatbotFiles, undefined, 2), 'utf-8')
50-
log.success(`\nCache file created @ ${cachePaths.chatbots}`)
49+
log.success(`\nCache file created @ ${cache.paths.chatbots}`)
5150
} catch (err) { // use existing cache file
52-
chatbotFiles = JSON.parse(fs.readFileSync(cachePaths.chatbots, 'utf-8'))
51+
chatbotFiles = JSON.parse(fs.readFileSync(cache.paths.chatbots, 'utf-8'))
5352
console.log(chatbotFiles)
5453
log.break()
5554
}

0 commit comments

Comments
 (0)