@platformatic/ts-compiler
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
'use strict' | ||
const { join, dirname } = require('path') | ||
const { readFile, rm } = require('fs/promises') | ||
const { readFile } = require('fs/promises') | ||
const setup = require('./lib/setup') | ||
const { safeRemove } = require('@platformatic/utils') | ||
@@ -25,3 +26,3 @@ async function compile (options = {}) { | ||
const env = { | ||
...process.env | ||
...process.env, | ||
} | ||
@@ -38,3 +39,3 @@ // Adding code coverage to the massive tsc executable will | ||
logger.info(`Removing build directory ${outDirFullPath}`) | ||
await rm(outDirFullPath, { recursive: true }) | ||
await safeRemove(outDirFullPath) | ||
} | ||
@@ -41,0 +42,0 @@ } |
@@ -19,3 +19,3 @@ 'use strict' | ||
translateTime: 'SYS:HH:MM:ss', | ||
ignore: 'hostname,pid' | ||
ignore: 'hostname,pid', | ||
}) | ||
@@ -22,0 +22,0 @@ ) |
{ | ||
"name": "@platformatic/ts-compiler", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"description": "Compiles TypeScript to JavaScript, Platformatic Edition", | ||
@@ -14,7 +14,7 @@ "main": "compile.js", | ||
"c8": "^10.0.0", | ||
"eslint": "9", | ||
"fastify": "^4.26.2", | ||
"neostandard": "^0.11.1", | ||
"pino-test": "^1.0.1", | ||
"snazzy": "^9.0.0", | ||
"standard": "^17.1.0", | ||
"typescript": "^5.5.3" | ||
"typescript": "^5.5.4" | ||
}, | ||
@@ -26,8 +26,8 @@ "dependencies": { | ||
"resolve": "^1.22.8", | ||
"@platformatic/utils": "2.0.0-alpha.2" | ||
"@platformatic/utils": "2.0.0-alpha.3" | ||
}, | ||
"scripts": { | ||
"test": "npm run lint && c8 node --test", | ||
"lint": "standard | snazzy" | ||
"lint": "eslint" | ||
} | ||
} |
@@ -5,3 +5,3 @@ 'use strict' | ||
const { join } = require('node:path') | ||
const { rm, writeFile, mkdir, readFile, access } = require('node:fs/promises') | ||
const { writeFile, readFile, access } = require('node:fs/promises') | ||
const assert = require('node:assert') | ||
@@ -13,2 +13,3 @@ const os = require('node:os') | ||
const { compile } = require('../compile.js') | ||
const { safeRemove, createDirectory } = require('@platformatic/utils') | ||
@@ -18,3 +19,3 @@ const tmpDir = os.tmpdir() | ||
test('empty folder', async (t) => { | ||
test('empty folder', async t => { | ||
process.chdir(tmpDir) | ||
@@ -32,19 +33,20 @@ t.after(() => { | ||
pinoTest.consecutive(stream, [ | ||
{ level: 40, msg: 'The tsc executable was not found.' } | ||
]) | ||
pinoTest.consecutive(stream, [{ level: 40, msg: 'The tsc executable was not found.' }]) | ||
}) | ||
test('successfully compile', async (t) => { | ||
test('successfully compile', async t => { | ||
const localTmpDir = join(tmpDir, 'compiled') | ||
await mkdir(join(localTmpDir), { recursive: true }) | ||
await createDirectory(join(localTmpDir), true) | ||
t.after(async () => { | ||
await rm(localTmpDir, { recursive: true }) | ||
await safeRemove(localTmpDir) | ||
}) | ||
await writeFile(join(localTmpDir, 'tsconfig.json'), JSON.stringify({ | ||
compilerOptions: { | ||
outDir: 'dist' | ||
} | ||
})) | ||
await writeFile( | ||
join(localTmpDir, 'tsconfig.json'), | ||
JSON.stringify({ | ||
compilerOptions: { | ||
outDir: 'dist', | ||
}, | ||
}) | ||
) | ||
@@ -60,5 +62,3 @@ await writeFile(join(localTmpDir, 'index.ts'), 'console.log("Hello, World!")') | ||
await pinoTest.consecutive(stream, [ | ||
{ level: 30, msg: 'Typescript compilation completed successfully.' } | ||
]) | ||
await pinoTest.consecutive(stream, [{ level: 30, msg: 'Typescript compilation completed successfully.' }]) | ||
@@ -69,14 +69,17 @@ const compiled = await readFile(join(localTmpDir, 'dist', 'index.js'), 'utf8') | ||
test('clean', async (t) => { | ||
test('clean', async t => { | ||
const localTmpDir = join(tmpDir, 'compiled') | ||
await mkdir(join(localTmpDir, 'dist'), { recursive: true }) | ||
await createDirectory(join(localTmpDir, 'dist'), true) | ||
t.after(async () => { | ||
await rm(localTmpDir, { recursive: true }) | ||
await safeRemove(localTmpDir) | ||
}) | ||
await writeFile(join(localTmpDir, 'tsconfig.json'), JSON.stringify({ | ||
compilerOptions: { | ||
outDir: 'dist' | ||
} | ||
})) | ||
await writeFile( | ||
join(localTmpDir, 'tsconfig.json'), | ||
JSON.stringify({ | ||
compilerOptions: { | ||
outDir: 'dist', | ||
}, | ||
}) | ||
) | ||
@@ -96,3 +99,3 @@ await writeFile(join(localTmpDir, 'dist', 'whaat'), '42') | ||
{ level: 30, msg: 'Removing build directory ' + join(localTmpDir, 'dist') }, | ||
{ level: 30, msg: 'Typescript compilation completed successfully.' } | ||
{ level: 30, msg: 'Typescript compilation completed successfully.' }, | ||
]) | ||
@@ -99,0 +102,0 @@ |
@@ -12,3 +12,3 @@ 'use strict' | ||
name: 'Error', | ||
message: 'The cwd option is required.' | ||
message: 'The cwd option is required.', | ||
}) | ||
@@ -15,0 +15,0 @@ }) |
21048
10
239
+ Added@platformatic/utils@2.0.0-alpha.3(transitive)
- Removed@platformatic/utils@2.0.0-alpha.2(transitive)