feat: renderSync, parseAndRenderSync and renderFileSync, see #48

This commit is contained in:
harttle
2019-08-26 10:15:43 -05:00
committed by Jun Yang
parent 8028f82499
commit 7fb01ad69a
66 changed files with 896 additions and 272 deletions
+15 -1
View File
@@ -44,8 +44,22 @@ async function readFile (url: string): Promise<string> {
})
}
function readFileSync (url: string): string {
const xhr = new XMLHttpRequest()
xhr.open('GET', url, false)
xhr.send()
if (xhr.status < 200 || xhr.status >= 300) {
throw new Error(xhr.statusText)
}
return xhr.responseText as string
}
async function exists () {
return true
}
export default { readFile, resolve, exists } as IFS
function existsSync () {
return true
}
export default { readFile, resolve, exists, existsSync, readFileSync } as IFS