Skip to content

Commit

Permalink
Test for directories and files with digit prefix (#10667)
Browse files Browse the repository at this point in the history
* Test for directories and files with digit prefix

* lint

(cherry picked from commit 5f540a7)
  • Loading branch information
KuphJr authored and chainchad committed Sep 18, 2023
1 parent ce1b34d commit 70736b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../../@ensdomains/buffer/0.1.0/Buffer.sol";
import "../../@ensdomains/buffer/v0.1.0/Buffer.sol";

/**
* @dev A library for populating CBOR encoded payload in Solidity.
Expand Down
31 changes: 31 additions & 0 deletions contracts/test/cross-version/directory.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fs from 'fs'
import path from 'path'
import { expect } from 'chai'

// Directories that start with a number do not currently work with typechain (https://github.com/dethcrypto/TypeChain/issues/794)
describe('Directory', () => {
it('Should not have a file or directory starting with a number in contracts/src', () => {
const srcPath = path.join(__dirname, '..', '..', 'src')

const noNumbersAsFirstChar = (dirPath: string): boolean => {
const entries = fs.readdirSync(dirPath, { withFileTypes: true })

for (const entry of entries) {
if (/^\d/.test(entry.name)) {
throw new Error(
`${path.join(dirPath, entry.name)} starts with a number`,
)
}

if (entry.isDirectory()) {
const newPath = path.join(dirPath, entry.name)
noNumbersAsFirstChar(newPath)
}
}

return true
}

expect(noNumbersAsFirstChar(srcPath)).to.be.true
})
})

0 comments on commit 70736b8

Please sign in to comment.