Compare commits

...

2 Commits

Author SHA1 Message Date
Chen Asraf
374b51e482 fix type import 2022-04-19 22:52:24 +03:00
Chen Asraf
5e175e6815 remove redundent check 2022-04-19 22:43:53 +03:00
5 changed files with 14 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "simple-scaffold",
"version": "1.1.0-alpha.4",
"version": "1.1.0-alpha.6",
"description": "Create files based on templates",
"repository": "https://github.com/chenasraf/simple-scaffold.git",
"author": "Chen Asraf <inbox@casraf.com>",

View File

@@ -11,7 +11,6 @@ import {
makeRelativePath,
registerHelpers,
getTemplateGlobInfo,
ensureFileExists,
getFileList,
getBasePath,
copyFileTransformed,
@@ -64,7 +63,6 @@ export async function Scaffold({ ...options }: ScaffoldConfig): Promise<void> {
options,
_template
)
await ensureFileExists(template, isDirOrGlob)
const files = await getFileList(options, template)
for (const inputFilePath of files) {
if (await isDir(inputFilePath)) {

View File

@@ -1,3 +1,5 @@
import { HelperDelegate } from "handlebars/runtime"
export enum LogLevel {
None = 0,
Debug = 1,
@@ -24,7 +26,7 @@ export type DefaultHelperKeys =
export type HelperKeys<T> = DefaultHelperKeys | T
export type Helper = Handlebars.HelperDelegate
export type Helper = HelperDelegate
export interface ScaffoldConfig {
/**

View File

@@ -245,16 +245,6 @@ export async function getTemplateGlobInfo(options: ScaffoldConfig, template: str
return { nonGlobTemplate, origTemplate, isDirOrGlob, isGlob, template: _template }
}
export async function ensureFileExists(template: string, isGlob: boolean): Promise<void> {
if (!isGlob && !(await pathExists(template))) {
const err: NodeJS.ErrnoException = new Error(`ENOENT, no such file or directory ${template}`)
err.code = "ENOENT"
err.path = template
err.errno = -2
throw err
}
}
export interface OutputFileInfo {
inputPath: string
outputPathOpt: string

View File

@@ -183,6 +183,16 @@ describe("Scaffold", () => {
})
).rejects.toThrow()
await expect(
Scaffold({
name: "app_name",
output: "output",
templates: ["non-existing-input/non-existing-file.txt"],
data: { value: "1" },
verbose: 0,
})
).rejects.toThrow()
expect(() => readFileSync(join(process.cwd(), "output", "app_name.txt"))).toThrow()
})
})