Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

feat: fail compilation if there are errors #2383

Merged
merged 4 commits into from
May 25, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions kernel/packages/build-ecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ async function compile() {
}

// First time around, emit all files
await emitFile(cfg.fileNames[0], services, cfg)
const diagnostics = await emitFile(cfg.fileNames[0], services, cfg)

if (!WATCH && diagnostics.length) {
throw new Error(`! Error: compilation finished with ${diagnostics.length} errors`)
}
}

function watchFile(fileName: string, services: ts.LanguageService, files: FileMap, cfg: ProjectConfig) {
Expand Down Expand Up @@ -184,7 +188,7 @@ async function emitFile(fileName: string, services: ts.LanguageService, cfg: Pro
console.log(`> processing ${fileName.replace(ts.sys.getCurrentDirectory(), '')} failed`)
}

logErrors(services)
const diagnostics = logErrors(services)

type OutFile = {
readonly path: string
Expand Down Expand Up @@ -335,6 +339,8 @@ async function emitFile(fileName: string, services: ts.LanguageService, cfg: Pro
if (WATCH) {
console.log('\nThe compiler is watching file changes...\n')
}

return diagnostics
}

function logErrors(services: ts.LanguageService) {
Expand All @@ -345,6 +351,8 @@ function logErrors(services: ts.LanguageService) {
.concat(services.getProgram()!.getSyntacticDiagnostics())

allDiagnostics.forEach(printDiagnostic)

return allDiagnostics
}

function getConfiguration(packageJson: PackageJson | null, sceneJson: SceneJson | null): ProjectConfig {
Expand Down Expand Up @@ -471,7 +479,7 @@ function getConfiguration(packageJson: PackageJson | null, sceneJson: SceneJson
if (resolved) {
try {
const libPackageJson = JSON.parse(ts.sys.readFile(resolved)!)
const decentralandLibrary = libPackageJson.decentralandLibrary;
const decentralandLibrary = libPackageJson.decentralandLibrary

let main: string | null = null
let typings: string | null = null
Expand Down