Skip to content

Commit 54a2d68

Browse files
committed
refactor: remove extraneous assertions from copyTemplateDir
This removes the `assert` calls we were making in `copyTemplateDir`, as well as the tests that exercise this behavior. These asserts probably made more sense in a pre-TypeScript world, but we no longer need them as TypeScript serves the same purpose.
1 parent f7e3ecd commit 54a2d68

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

src/utils/copy-template-dir/copy-template-dir.ts

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import assert from 'assert'
2221
import fs from 'fs'
2322
import path from 'path'
2423
import { pipeline } from 'stream'
@@ -53,10 +52,6 @@ async function writeFile(outDir: string, vars: Record<string, string>, file: Ent
5352

5453
// High throughput template dir writes
5554
export async function copyTemplateDir(srcDir: string, outDir: string, vars: Record<string, string>): Promise<string[]> {
56-
assert.strictEqual(typeof srcDir, 'string')
57-
assert.strictEqual(typeof outDir, 'string')
58-
assert.strictEqual(typeof vars, 'object')
59-
6055
await fs.promises.mkdir(outDir, { recursive: true })
6156

6257
const rs: ReaddirpStream = readdirp(srcDir)

tests/unit/utils/copy-template-dir/copy-template-dir.test.ts

-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ const __filename = fileURLToPath(import.meta.url)
1111
const __dirname = path.dirname(__filename)
1212

1313
describe('copyTemplateDir', () => {
14-
test('should assert input values', async () => {
15-
// @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 0.
16-
await expect(copyTemplateDir()).rejects.toThrow(/string/)
17-
// @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 1.
18-
await expect(copyTemplateDir('foo')).rejects.toThrow(/string/)
19-
await expect(copyTemplateDir('foo', 'bar', 'err')).rejects.toThrow(/object/)
20-
})
21-
2214
test('should write a bunch of files', async () => {
2315
const checkCreatedFileNames = (names: string[]) => {
2416
expect(names).toContain('.a')

0 commit comments

Comments
 (0)