diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e11332821..b9534cfb8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,14 +1,3 @@ - - #### What this PR does / why we need it: #### Which issue(s) will this PR fix?: - - - -Fixes # - -#### Additional comments?: diff --git a/workspace/sync-trustwallet-assets/src/sync.ts b/workspace/sync-trustwallet-assets/src/sync.ts index 6fcc59362..d77241ebb 100644 --- a/workspace/sync-trustwallet-assets/src/sync.ts +++ b/workspace/sync-trustwallet-assets/src/sync.ts @@ -44,15 +44,15 @@ export abstract class Sync { async shouldWrite(dir: string, info: Partial): Promise { // Make sure logo.png and info.json exists - const fromLogoStats = await stat(`${this.from}/${dir}/logo.png`); - const fromInfoStats = await stat(`${this.from}/${dir}/info.json`); - if (!fromLogoStats.isFile() || !fromInfoStats.isFile()) return false; + const hasFromLogo = await hasFile(`${this.from}/${dir}/logo.png`); + const hasFromInfo = await hasFile(`${this.from}/${dir}/info.json`); + if (!hasFromLogo || !hasFromInfo) return false; // If README.md and logo.png do not exist on the other side, write it const namespace = this.getNamespace(info); - const toLogoStats = await stat(`${this.to}/${namespace}/logo.png`); - const toReadmeStats = await stat(`${this.to}/${namespace}/README.md`); - if (!toLogoStats.isFile() || !toReadmeStats.isFile()) return true; + const hasToLogo = await hasFile(`${this.to}/${namespace}/logo.png`); + const hasToReadme = await hasFile(`${this.to}/${namespace}/README.md`); + if (!hasToLogo || !hasToReadme) return true; // Otherwise, allow overwriting if the author is Frontmatter Bot const name = await getAuthorName(`${this.to}/${namespace}/README.md`); @@ -80,6 +80,13 @@ export abstract class Sync { } } +function hasFile(filepath: string): Promise { + return stat(filepath).then( + () => true, + () => false, + ); +} + export class Eip155Sync extends Sync { async write(dir: string, info: Partial): Promise { const namespace = this.getNamespace(info);