Simplify the checking for existing files.

pull/5370/head
Evan Sangaline 10 months ago committed by Aniket
parent c8c2051bfb
commit 2baaaa97e0
  1. 20
      libs/remix-ws-templates/src/script-templates/sindri/index.ts

@ -4,15 +4,10 @@ export const sindriScripts = async (plugin) => {
// @ts-ignore // @ts-ignore
(await import('!!raw-loader!./sindri.ts')).default) (await import('!!raw-loader!./sindri.ts')).default)
const existingFiles = await plugin.call('fileManager', 'readdir', '')
// Only write out the `.sindriignore` file if it doesn't already exist. // Only write out the `.sindriignore` file if it doesn't already exist.
let sindriIgnoreExists: boolean if (!('.sindriignore' in existingFiles)) {
try {
await plugin.call('fileManager', 'readFile', './.sindriignore')
sindriIgnoreExists = true
} catch {
sindriIgnoreExists = false
}
if (!sindriIgnoreExists) {
await plugin.call('fileManager', 'writeFile', await plugin.call('fileManager', 'writeFile',
'.sindriignore', '.sindriignore',
// @ts-ignore // @ts-ignore
@ -20,14 +15,7 @@ export const sindriScripts = async (plugin) => {
} }
// Only write out the `sindri.json` file if it doesn't already exist. // Only write out the `sindri.json` file if it doesn't already exist.
let sindriJsonExists: boolean if (!('sindri.json' in existingFiles)) {
try {
await plugin.call('fileManager', 'readFile', './sindri.json')
sindriJsonExists = true
} catch {
sindriJsonExists = false
}
if (!sindriJsonExists) {
await plugin.call('fileManager', 'writeFile', await plugin.call('fileManager', 'writeFile',
'sindri.json', 'sindri.json',
// @ts-ignore // @ts-ignore

Loading…
Cancel
Save