You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@jetkit/cdk

Package Overview
Dependencies
Maintainers
5
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jetkit/cdk

Cloud-native serverless anti-framework

2.0.18
latest
Source
npmnpm
Version published
Maintainers
5
Created
Source

import { createProjectSync, ts } from "@ts-morph/bootstrap" import * as fs from "fs" import * as path from "path" import { default as SimpleMarkdown } from "simple-markdown"

const projectRootDir = "."

describe("README examples", () => { const readmePath = path.join(projectRootDir, "README.md") const readmeContents = fs.readFileSync(readmePath)

// extract examples const parser = SimpleMarkdown.parserFor(SimpleMarkdown.defaultRules) const parsed = parser(readmeContents.toString())

let exampleNum = 1 parsed.forEach((block) => { if (block.type !== "codeBlock" || block.lang != "typescript") return

describe(`compiles example ${exampleNum++}`, () => {
  compile(block.content)
  expect(true).toBeTruthy()
})

}) })

function compile(input: string): void { const project = createProjectSync({ tsConfigFilePath: "packages/cdk/tsconfig.json", compilerOptions: { noEmit: true, }, })

// build program project.createSourceFile("packages/cdk/src/example.ts", input) const program = project.createProgram()

// try to compile const emitResult = program.emit()

// get errors const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)

allDiagnostics.forEach((diagnostic) => { if (diagnostic.file) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!) const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") console.log(${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}) } else { console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")) } })

it("compiles without errors or warnings", () => { expect(allDiagnostics).toHaveLength(0) expect(emitResult.emitSkipped).toBeFalsy() }) }

Keywords

aws

FAQs

Package last updated on 29 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts