mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
build(deps): update latest, fix issue with jest
This commit is contained in:
parent
d795650689
commit
d934d6e7c2
@ -1,6 +1,6 @@
|
|||||||
import readline from 'node:readline'
|
import readline from 'node:readline'
|
||||||
|
|
||||||
const removeByIndex = <T = any>(array: T[], index: number): T[] => {
|
const removeByIndex = <T = unknown>(array: T[], index: number): T[] => {
|
||||||
const result = [...array]
|
const result = [...array]
|
||||||
result.splice(index, 1)
|
result.splice(index, 1)
|
||||||
return result
|
return result
|
||||||
|
@ -36,7 +36,9 @@ export class GenerateChallengeCommand extends Command {
|
|||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${chalk.bold.red('Error:')} ${error.message as string}`)
|
if (error instanceof Error) {
|
||||||
|
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,9 @@ export class GenerateSolutionCommand extends Command {
|
|||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${chalk.bold.red('Error:')} ${error.message as string}`)
|
if (error instanceof Error) {
|
||||||
|
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,9 @@ export class RunTestCommand extends Command {
|
|||||||
console.log(successMessage)
|
console.log(successMessage)
|
||||||
return 0
|
return 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`\n${chalk.bold.red('Error:')} ${error.message as string}`)
|
if (error instanceof Error) {
|
||||||
|
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,55 @@ describe('utils/copyDirectory', () => {
|
|||||||
expect.arrayContaining(['default.png', 'index.ts', '.npmignore'])
|
expect.arrayContaining(['default.png', 'index.ts', '.npmignore'])
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('copy the files and folders recursively', async () => {
|
||||||
|
fsMock({
|
||||||
|
'/source': {
|
||||||
|
'random-folder': {
|
||||||
|
'default.png': '',
|
||||||
|
'second-random-folder': {
|
||||||
|
'mycode.ts': ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'index.ts': '',
|
||||||
|
'.npmignore': ''
|
||||||
|
},
|
||||||
|
'/destination': {}
|
||||||
|
})
|
||||||
|
|
||||||
|
let destinationDirectoryContent = await fs.promises.readdir('/destination')
|
||||||
|
let sourceDirectoryContent = await fs.promises.readdir('/source')
|
||||||
|
let randomFolderContent = await fs.promises.readdir('/source/random-folder')
|
||||||
|
let secondRandomFolderContent = await fs.promises.readdir(
|
||||||
|
'/source/random-folder/second-random-folder'
|
||||||
|
)
|
||||||
|
expect(randomFolderContent.length).toEqual(2)
|
||||||
|
expect(secondRandomFolderContent.length).toEqual(1)
|
||||||
|
expect(destinationDirectoryContent.length).toEqual(0)
|
||||||
|
expect(sourceDirectoryContent.length).toEqual(3)
|
||||||
|
|
||||||
|
await copyDirectory('/source', '/destination')
|
||||||
|
destinationDirectoryContent = await fs.promises.readdir('/destination')
|
||||||
|
sourceDirectoryContent = await fs.promises.readdir('/source')
|
||||||
|
randomFolderContent = await fs.promises.readdir('/destination/random-folder')
|
||||||
|
secondRandomFolderContent = await fs.promises.readdir(
|
||||||
|
'/destination/random-folder/second-random-folder'
|
||||||
|
)
|
||||||
|
expect(destinationDirectoryContent.length).toEqual(3)
|
||||||
|
expect(sourceDirectoryContent.length).toEqual(3)
|
||||||
|
expect(destinationDirectoryContent).toEqual(
|
||||||
|
expect.arrayContaining(['random-folder', 'index.ts', '.npmignore'])
|
||||||
|
)
|
||||||
|
expect(sourceDirectoryContent).toEqual(
|
||||||
|
expect.arrayContaining(['random-folder', 'index.ts', '.npmignore'])
|
||||||
|
)
|
||||||
|
expect(randomFolderContent.length).toEqual(2)
|
||||||
|
expect(secondRandomFolderContent.length).toEqual(1)
|
||||||
|
expect(randomFolderContent).toEqual(
|
||||||
|
expect.arrayContaining(['default.png', 'second-random-folder'])
|
||||||
|
)
|
||||||
|
expect(secondRandomFolderContent).toEqual(
|
||||||
|
expect.arrayContaining(['mycode.ts'])
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
3679
package-lock.json
generated
3679
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -36,31 +36,31 @@
|
|||||||
"lint:typescript": "ts-standard"
|
"lint:typescript": "ts-standard"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "4.1.1",
|
"chalk": "4.1.2",
|
||||||
"clipanion": "3.0.0-rc.12",
|
"clipanion": "3.0.1",
|
||||||
"date-and-time": "1.0.1",
|
"date-and-time": "2.0.0",
|
||||||
"execa": "5.1.1",
|
"execa": "5.1.1",
|
||||||
"ora": "5.4.1",
|
"ora": "5.4.1",
|
||||||
"replace-in-file": "6.2.0",
|
"replace-in-file": "6.2.0",
|
||||||
"table": "6.7.1",
|
"table": "6.7.1",
|
||||||
"typanion": "3.3.1",
|
"typanion": "3.3.2",
|
||||||
"validate-npm-package-name": "3.0.0"
|
"validate-npm-package-name": "3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "12.1.4",
|
"@commitlint/cli": "13.1.0",
|
||||||
"@commitlint/config-conventional": "12.1.4",
|
"@commitlint/config-conventional": "13.1.0",
|
||||||
"@types/date-and-time": "0.13.0",
|
"@types/date-and-time": "0.13.0",
|
||||||
"@types/jest": "26.0.23",
|
"@types/jest": "27.0.1",
|
||||||
"@types/mock-fs": "4.13.0",
|
"@types/mock-fs": "4.13.1",
|
||||||
"@types/node": "16.0.0",
|
"@types/node": "16.7.2",
|
||||||
"@types/validate-npm-package-name": "3.0.3",
|
"@types/validate-npm-package-name": "3.0.3",
|
||||||
"editorconfig-checker": "4.0.2",
|
"editorconfig-checker": "4.0.2",
|
||||||
"jest": "27.0.6",
|
"jest": "27.1.0",
|
||||||
"markdownlint-cli": "0.27.1",
|
"markdownlint-cli": "0.28.1",
|
||||||
"mock-fs": "5.0.0",
|
"mock-fs": "5.0.0",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"ts-jest": "27.0.3",
|
"ts-jest": "27.0.5",
|
||||||
"ts-standard": "10.0.0",
|
"ts-standard": "10.0.0",
|
||||||
"typescript": "4.3.5"
|
"typescript": "4.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user