Comparing version 0.0.3-9 to 0.0.3-10
@@ -7,2 +7,3 @@ #!/usr/bin/env ts-node | ||
const compile_1 = require("./cli/compile"); | ||
const info_1 = require("./cli/info"); | ||
const init_1 = require("./cli/init"); | ||
@@ -25,2 +26,4 @@ const install_1 = require("./cli/install"); | ||
return result_1.Ok("install"); | ||
case "info": | ||
return result_1.Ok("info"); | ||
default: { | ||
@@ -36,2 +39,3 @@ return result_1.Err(`Unknown command \`${process.argv[2]}\``); | ||
console.log("Or compile and test via `test`"); | ||
console.log("Or get info about a file or package via `info`"); | ||
} | ||
@@ -45,21 +49,26 @@ async function main() { | ||
} | ||
const argv = process.argv; | ||
const isInPackageDirectory = await utils_1.fileExists("derw-package.json"); | ||
switch (command.value) { | ||
case "compile": { | ||
await compile_1.compileFiles(isInPackageDirectory); | ||
await compile_1.compileFiles(isInPackageDirectory, argv); | ||
return 0; | ||
} | ||
case "init": { | ||
await init_1.init(isInPackageDirectory); | ||
await init_1.init(isInPackageDirectory, argv); | ||
return 0; | ||
} | ||
case "install": { | ||
await install_1.install(isInPackageDirectory); | ||
await install_1.install(isInPackageDirectory, argv); | ||
return 0; | ||
} | ||
case "test": { | ||
await compile_1.compileFiles(isInPackageDirectory); | ||
await testing_1.runTests(isInPackageDirectory); | ||
await compile_1.compileFiles(isInPackageDirectory, argv); | ||
await testing_1.runTests(isInPackageDirectory, argv); | ||
return 0; | ||
} | ||
case "info": { | ||
await info_1.info(isInPackageDirectory, argv); | ||
return 0; | ||
} | ||
} | ||
@@ -66,0 +75,0 @@ } |
@@ -1,1 +0,3 @@ | ||
export declare function compileFiles(isInPackageDirectory: boolean): Promise<void>; | ||
import { ContextModule } from "../types"; | ||
export declare type ProcessedFiles = Record<string, ContextModule>; | ||
export declare function compileFiles(isInPackageDirectory: boolean, argv: string[]): Promise<ProcessedFiles>; |
@@ -33,5 +33,7 @@ "use strict"; | ||
const compile_1 = require("../compile"); | ||
const names_1 = require("../errors/names"); | ||
const generator_1 = require("../generator"); | ||
const package_1 = require("../package"); | ||
const derwParser = __importStar(require("../parser")); | ||
const types_1 = require("../types"); | ||
const utils_1 = require("./utils"); | ||
@@ -47,2 +49,3 @@ const compileParser = baner_1.parser([ | ||
baner_1.longFlag("format", "Format the files given in-place", baner_1.empty()), | ||
baner_1.longFlag("names", "Check for missing names out of scope", baner_1.empty()), | ||
baner_1.longFlag("quiet", "Keep it short and sweet", baner_1.empty()), | ||
@@ -82,5 +85,18 @@ baner_1.bothFlag("h", "help", "This help text", baner_1.empty()), | ||
async function getDerwFiles(dir) { | ||
return await (await promises_1.readdir(path_1.default.join(dir, "src"))) | ||
.map((file) => path_1.default.join(dir, "src", file)) | ||
.filter((file) => file.endsWith("derw")); | ||
let files = []; | ||
for (const file of await promises_1.readdir(dir, { withFileTypes: true })) { | ||
if (file.isFile()) { | ||
if (file.name.endsWith("derw")) { | ||
files.push(path_1.default.join(dir, file.name)); | ||
} | ||
} | ||
else if (file.isDirectory()) { | ||
if (file.name === "node_modules") { | ||
} | ||
else { | ||
files = files.concat(await getDerwFiles(path_1.default.join(dir, file.name))); | ||
} | ||
} | ||
} | ||
return files; | ||
} | ||
@@ -118,7 +134,7 @@ function filterBodyForName(module, name) { | ||
} | ||
async function compileFiles(isInPackageDirectory) { | ||
const program = baner_1.parse(compileParser, process.argv); | ||
async function compileFiles(isInPackageDirectory, argv) { | ||
const program = baner_1.parse(compileParser, argv); | ||
if (program.flags["h/help"].isPresent) { | ||
showCompileHelp(); | ||
return; | ||
return {}; | ||
} | ||
@@ -137,7 +153,8 @@ const errors = baner_1.allErrors(program); | ||
const debugMode = program.flags["debug"].isPresent; | ||
const files = isInPackageDirectory | ||
? await getDerwFiles("./") | ||
const isPackageDirectoryAndNoFilesPassed = isInPackageDirectory && !program.flags.files.isPresent; | ||
const files = isPackageDirectoryAndNoFilesPassed | ||
? await getDerwFiles("./src") | ||
: program.flags.files.arguments.value; | ||
if (isInPackageDirectory) { | ||
const packageFile = package_1.decodePackage(JSON.parse(await (await promises_1.readFile("derw-package.json")).toString())); | ||
if (isPackageDirectoryAndNoFilesPassed) { | ||
const packageFile = await package_1.loadPackageFile("derw-package.json"); | ||
if (packageFile.kind === "err") { | ||
@@ -150,3 +167,3 @@ console.log("Failed to parse package file due to:"); | ||
for (const dep of validPackage.dependencies) { | ||
for (const file of await getDerwFiles(`derw-packages/${dep.name}`)) { | ||
for (const file of await getDerwFiles(`derw-packages/${dep.name}/src`)) { | ||
files.push(file); | ||
@@ -178,2 +195,4 @@ } | ||
const processedFiles = []; | ||
const parsedFiles = {}; | ||
const parsedImports = {}; | ||
for (const fileName of files) { | ||
@@ -196,3 +215,6 @@ await (async function compile(fileName) { | ||
const isMain = files.indexOf(fileName) > -1; | ||
const parsed = derwParser.parse(derwContents, isMain ? "Main" : fileName); | ||
let parsed = derwParser.parseWithContext(derwContents, isMain ? "Main" : fileName); | ||
if (program.flags.names.isPresent) { | ||
parsed = names_1.addMissingNamesSuggestions(parsed); | ||
} | ||
if (parsed.errors.length > 0) { | ||
@@ -203,2 +225,3 @@ console.log(`Failed to parse ${fileName} due to:`); | ||
} | ||
parsedFiles[fileName] = parsed; | ||
const dir = path_1.default.dirname(fileName); | ||
@@ -220,6 +243,10 @@ const imports = []; | ||
}); | ||
parsedImports[fileName] = []; | ||
for (const import_ of imports) { | ||
const fileWithDerwExtension = import_ + `.derw`; | ||
const fileWithDerwExtension = import_.endsWith(".derw") | ||
? import_ | ||
: import_ + `.derw`; | ||
const isDerw = await utils_1.fileExists(fileWithDerwExtension); | ||
if (isDerw) { | ||
parsedImports[fileName].push(fileWithDerwExtension); | ||
await compile(fileWithDerwExtension); | ||
@@ -258,3 +285,13 @@ continue; | ||
} | ||
const generated = generator_1.generate(target, parsed); | ||
const importedContextModules = []; | ||
for (const import_ of parsedImports[fileName]) { | ||
importedContextModules.push(parsedFiles[import_]); | ||
} | ||
parsed = derwParser.addTypeErrors(parsed, importedContextModules); | ||
if (parsed.errors.length > 0) { | ||
console.log(`Failed to parse ${fileName} due to:`); | ||
console.log(parsed.errors.join("\n")); | ||
return; | ||
} | ||
const generated = generator_1.generate(target, types_1.contextModuleToModule(parsed)); | ||
if (program.flags.verify.isPresent && target === "ts") { | ||
@@ -288,3 +325,4 @@ const output = compile_1.compileTypescript(generated); | ||
} | ||
return parsedFiles; | ||
} | ||
exports.compileFiles = compileFiles; |
@@ -1,1 +0,1 @@ | ||
export declare function init(isInPackageDirectory: boolean): Promise<void>; | ||
export declare function init(isInPackageDirectory: boolean, argv: string[]): Promise<void>; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.init = void 0; | ||
const baner_1 = require("@eeue56/baner"); | ||
const promises_1 = require("fs/promises"); | ||
@@ -12,3 +13,10 @@ const path_1 = __importDefault(require("path")); | ||
const utils_1 = require("./utils"); | ||
async function copyTSconfig() { | ||
const initParser = baner_1.parser([ | ||
baner_1.longFlag("dir", "name of a directory to get info about e.g stdlib", baner_1.string()), | ||
baner_1.bothFlag("h", "help", "This help text", baner_1.empty()), | ||
]); | ||
function showInfoHelp() { | ||
console.log(baner_1.help(initParser)); | ||
} | ||
async function copyTSconfig(dir) { | ||
const tsconfig = { | ||
@@ -31,10 +39,18 @@ compilerOptions: { | ||
}; | ||
if (await utils_1.fileExists("tsconfig.json")) { | ||
if (await utils_1.fileExists(path_1.default.join(dir, "tsconfig.json"))) { | ||
console.log("Already got a tsconfig!"); | ||
return -1; | ||
process.exit(1); | ||
} | ||
await promises_1.writeFile("tsconfig.json", JSON.stringify(tsconfig, null, 4)); | ||
await promises_1.writeFile(path_1.default.join(dir, "tsconfig.json"), JSON.stringify(tsconfig, null, 4)); | ||
} | ||
async function init(isInPackageDirectory) { | ||
const packageName = path_1.default.basename(process.cwd()); | ||
async function init(isInPackageDirectory, argv) { | ||
const program = baner_1.parse(initParser, argv); | ||
if (program.flags["h/help"].isPresent) { | ||
showInfoHelp(); | ||
return; | ||
} | ||
const dir = program.flags.dir.isPresent && program.flags.dir.arguments.kind === "ok" | ||
? program.flags.dir.arguments.value | ||
: process.cwd(); | ||
const packageName = path_1.default.basename(dir); | ||
const package_ = package_1.Package(packageName, [], []); | ||
@@ -45,5 +61,5 @@ if (isInPackageDirectory) { | ||
} | ||
await promises_1.writeFile("derw-package.json", package_1.exportPackage(package_)); | ||
await copyTSconfig(); | ||
await utils_1.ensureDirectoryExists("src"); | ||
await promises_1.writeFile(path_1.default.join(dir, "derw-package.json"), package_1.exportPackage(package_)); | ||
await copyTSconfig(dir); | ||
await utils_1.ensureDirectoryExists(path_1.default.join(dir, "src")); | ||
console.log("Project initialized!"); | ||
@@ -50,0 +66,0 @@ console.log("Put your files in `src`"); |
@@ -1,1 +0,1 @@ | ||
export declare function install(isInPackageDirectory: boolean): Promise<void>; | ||
export declare function install(isInPackageDirectory: boolean, argv: string[]): Promise<void>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.install = void 0; | ||
const baner_1 = require("@eeue56/baner"); | ||
const result_1 = require("@eeue56/ts-core/build/main/lib/result"); | ||
const child_process_1 = require("child_process"); | ||
const promises_1 = require("fs/promises"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const package_1 = require("../package"); | ||
@@ -20,3 +25,3 @@ const utils_1 = require("./utils"); | ||
} | ||
async function install(isInPackageDirectory) { | ||
async function install(isInPackageDirectory, argv) { | ||
if (!isInPackageDirectory) { | ||
@@ -26,3 +31,3 @@ console.log("No derw-package.json found. Maybe you need to run `derw init` first?"); | ||
} | ||
const program = baner_1.parse(installParser, process.argv); | ||
const program = baner_1.parse(installParser, argv); | ||
if (program.flags["h/help"].isPresent) { | ||
@@ -34,3 +39,3 @@ showInstallHelp(); | ||
const isInstallNewPackage = program.flags.name.isPresent; | ||
const packageFile = package_1.decodePackage(JSON.parse(await (await promises_1.readFile("derw-package.json")).toString())); | ||
const packageFile = await package_1.loadPackageFile("derw-package.json"); | ||
if (packageFile.kind === "err") { | ||
@@ -44,3 +49,3 @@ console.log("Failed to parse package file due to:"); | ||
const name = program.flags.name.arguments.value; | ||
let version = "master;"; | ||
let version = "main"; | ||
if (program.flags.version.isPresent) { | ||
@@ -72,10 +77,36 @@ version = program.flags.version.arguments.value; | ||
exports.install = install; | ||
function isPackageAlreadyThere(package_, packages) { | ||
for (const p of packages) { | ||
if (package_.name === p.name) | ||
return true; | ||
} | ||
return false; | ||
} | ||
async function installPackages(validPackage, isQuiet) { | ||
await utils_1.ensureDirectoryExists("derw-packages"); | ||
const installedPackages = []; | ||
for (const dependency of validPackage.dependencies) { | ||
if (!isQuiet) | ||
console.log(`Fetching ${dependency.name}@${dependency.version}...`); | ||
const depPackage = await fetchDependencyPackage(dependency); | ||
if (depPackage.kind === "ok") { | ||
if (!isPackageAlreadyThere(depPackage.value, installedPackages)) { | ||
const subpackages = await installPackages(depPackage.value, isQuiet); | ||
for (const subpackage of subpackages) { | ||
installedPackages.push(subpackage); | ||
} | ||
} | ||
} | ||
await cloneRepo(dependency); | ||
await checkoutRef(dependency); | ||
if (await utils_1.fileExists(`derw-packages/${dependency.name}/package.json`)) { | ||
if (!isQuiet) | ||
console.log("Installing npm packages..."); | ||
await npmInstall(dependency); | ||
} | ||
if (depPackage.kind === "ok") { | ||
installedPackages.push(depPackage.value); | ||
} | ||
} | ||
return installedPackages; | ||
} | ||
@@ -96,6 +127,6 @@ async function cloneRepo(dependency) { | ||
if (res.error) { | ||
console.log(`Encountered error cloning ${dependency.name}`); | ||
console.log(`Encountered error fetching ${dependency.name}`); | ||
console.log(res.error); | ||
} | ||
res = child_process_1.spawnSync("git", ["checkout", `${dependency.version}`], { | ||
res = child_process_1.spawnSync("git", ["reset", "--hard", `origin/${dependency.version}`], { | ||
cwd: `derw-packages/${dependency.name}`, | ||
@@ -105,5 +136,33 @@ encoding: "utf-8", | ||
if (res.error) { | ||
console.log(`Encountered error cloning ${dependency.name}`); | ||
console.log(`Encountered error checkout ${dependency.name}`); | ||
console.log(res.error); | ||
} | ||
res = child_process_1.spawnSync("git", ["reset", "--hard", `${dependency.version}`], { | ||
cwd: `derw-packages/${dependency.name}`, | ||
encoding: "utf-8", | ||
}); | ||
if (res.error) { | ||
console.log(`Encountered error checkout ${dependency.name}`); | ||
console.log(res.error); | ||
} | ||
} | ||
async function npmInstall(dependency) { | ||
const res = child_process_1.spawnSync("npm", ["install"], { | ||
cwd: `derw-packages/${dependency.name}`, | ||
encoding: "utf-8", | ||
}); | ||
if (res.error) { | ||
console.log(`Encountered error installing npm packages from ${dependency.name}`); | ||
console.log(res.error); | ||
} | ||
} | ||
async function fetchDependencyPackage(dependency) { | ||
try { | ||
const response = await node_fetch_1.default(`https://raw.githubusercontent.com/${dependency.name}/${dependency.version}/derw-package.json`); | ||
return package_1.decodePackage(await response.json()); | ||
} | ||
catch (error) { | ||
console.log(error); | ||
return result_1.Err(`Failed to fetch ${dependency.name}@${dependency.version}`); | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
export declare function runTests(isInPackageDirectory: boolean): Promise<void>; | ||
export declare function runTests(isInPackageDirectory: boolean, argv: string[]): Promise<void>; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const bach_1 = require("@eeue56/bach/build/bach"); | ||
async function runTests(isInPackageDirectory) { | ||
async function runTests(isInPackageDirectory, argv) { | ||
if (!isInPackageDirectory) { | ||
@@ -8,0 +8,0 @@ console.log("Must run tests from the root of a package directory."); |
@@ -229,29 +229,29 @@ "use strict"; | ||
function generateEquality(equality) { | ||
const left = generateExpression(equality.leftHand); | ||
const right = generateExpression(equality.rightHand); | ||
const left = generateExpression(equality.left); | ||
const right = generateExpression(equality.right); | ||
return `${left} == ${right}`; | ||
} | ||
function generateInEquality(inEquality) { | ||
const left = generateExpression(inEquality.leftHand); | ||
const right = generateExpression(inEquality.rightHand); | ||
const left = generateExpression(inEquality.left); | ||
const right = generateExpression(inEquality.right); | ||
return `${left} != ${right}`; | ||
} | ||
function generateLessThan(lessThan) { | ||
const left = generateExpression(lessThan.leftHand); | ||
const right = generateExpression(lessThan.rightHand); | ||
const left = generateExpression(lessThan.left); | ||
const right = generateExpression(lessThan.right); | ||
return `${left} < ${right}`; | ||
} | ||
function generateLessThanOrEqual(lessThanOrEqual) { | ||
const left = generateExpression(lessThanOrEqual.leftHand); | ||
const right = generateExpression(lessThanOrEqual.rightHand); | ||
const left = generateExpression(lessThanOrEqual.left); | ||
const right = generateExpression(lessThanOrEqual.right); | ||
return `${left} <= ${right}`; | ||
} | ||
function generateGreaterThan(greaterThan) { | ||
const left = generateExpression(greaterThan.leftHand); | ||
const right = generateExpression(greaterThan.rightHand); | ||
const left = generateExpression(greaterThan.left); | ||
const right = generateExpression(greaterThan.right); | ||
return `${left} > ${right}`; | ||
} | ||
function generateGreaterThanOrEqual(greaterThanOrEqual) { | ||
const left = generateExpression(greaterThanOrEqual.leftHand); | ||
const right = generateExpression(greaterThanOrEqual.rightHand); | ||
const left = generateExpression(greaterThanOrEqual.left); | ||
const right = generateExpression(greaterThanOrEqual.right); | ||
return `${left} >= ${right}`; | ||
@@ -258,0 +258,0 @@ } |
@@ -255,29 +255,29 @@ "use strict"; | ||
function generateEquality(equality) { | ||
const left = generateExpression(equality.leftHand); | ||
const right = generateExpression(equality.rightHand); | ||
const left = generateExpression(equality.left); | ||
const right = generateExpression(equality.right); | ||
return `${left} == ${right}`; | ||
} | ||
function generateInEquality(inEquality) { | ||
const left = generateExpression(inEquality.leftHand); | ||
const right = generateExpression(inEquality.rightHand); | ||
const left = generateExpression(inEquality.left); | ||
const right = generateExpression(inEquality.right); | ||
return `${left} != ${right}`; | ||
} | ||
function generateLessThan(lessThan) { | ||
const left = generateExpression(lessThan.leftHand); | ||
const right = generateExpression(lessThan.rightHand); | ||
const left = generateExpression(lessThan.left); | ||
const right = generateExpression(lessThan.right); | ||
return `${left} < ${right}`; | ||
} | ||
function generateLessThanOrEqual(lessThanOrEqual) { | ||
const left = generateExpression(lessThanOrEqual.leftHand); | ||
const right = generateExpression(lessThanOrEqual.rightHand); | ||
const left = generateExpression(lessThanOrEqual.left); | ||
const right = generateExpression(lessThanOrEqual.right); | ||
return `${left} <= ${right}`; | ||
} | ||
function generateGreaterThan(greaterThan) { | ||
const left = generateExpression(greaterThan.leftHand); | ||
const right = generateExpression(greaterThan.rightHand); | ||
const left = generateExpression(greaterThan.left); | ||
const right = generateExpression(greaterThan.right); | ||
return `${left} > ${right}`; | ||
} | ||
function generateGreaterThanOrEqual(greaterThanOrEqual) { | ||
const left = generateExpression(greaterThanOrEqual.leftHand); | ||
const right = generateExpression(greaterThanOrEqual.rightHand); | ||
const left = generateExpression(greaterThanOrEqual.left); | ||
const right = generateExpression(greaterThanOrEqual.right); | ||
return `${left} >= ${right}`; | ||
@@ -284,0 +284,0 @@ } |
@@ -42,2 +42,4 @@ "use strict"; | ||
function generateObjectLiteral(literal) { | ||
if (literal.fields.length === 0) | ||
return `{ }`; | ||
let fields = literal.fields.map(generateField).join(",\n "); | ||
@@ -98,2 +100,4 @@ if (literal.fields.length === 1) | ||
function generateBranch(predicate, branch) { | ||
const body = generateExpression(branch.body); | ||
const returnWrapper = types_1.isSimpleValue(branch.body.kind) ? "return " : ""; | ||
switch (branch.pattern.kind) { | ||
@@ -105,3 +109,3 @@ case "Destructure": { | ||
return `case "${branch.pattern.constructor}": {${pattern} | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -111,3 +115,3 @@ } | ||
return `case "${branch.pattern.body}": { | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -117,3 +121,3 @@ } | ||
return `default: { | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -260,29 +264,29 @@ } | ||
function generateEquality(equality) { | ||
const left = generateExpression(equality.leftHand); | ||
const right = generateExpression(equality.rightHand); | ||
const left = generateExpression(equality.left); | ||
const right = generateExpression(equality.right); | ||
return `${left} === ${right}`; | ||
} | ||
function generateInEquality(inEquality) { | ||
const left = generateExpression(inEquality.leftHand); | ||
const right = generateExpression(inEquality.rightHand); | ||
const left = generateExpression(inEquality.left); | ||
const right = generateExpression(inEquality.right); | ||
return `${left} !== ${right}`; | ||
} | ||
function generateLessThan(lessThan) { | ||
const left = generateExpression(lessThan.leftHand); | ||
const right = generateExpression(lessThan.rightHand); | ||
const left = generateExpression(lessThan.left); | ||
const right = generateExpression(lessThan.right); | ||
return `${left} < ${right}`; | ||
} | ||
function generateLessThanOrEqual(lessThanOrEqual) { | ||
const left = generateExpression(lessThanOrEqual.leftHand); | ||
const right = generateExpression(lessThanOrEqual.rightHand); | ||
const left = generateExpression(lessThanOrEqual.left); | ||
const right = generateExpression(lessThanOrEqual.right); | ||
return `${left} <= ${right}`; | ||
} | ||
function generateGreaterThan(greaterThan) { | ||
const left = generateExpression(greaterThan.leftHand); | ||
const right = generateExpression(greaterThan.rightHand); | ||
const left = generateExpression(greaterThan.left); | ||
const right = generateExpression(greaterThan.right); | ||
return `${left} > ${right}`; | ||
} | ||
function generateGreaterThanOrEqual(greaterThanOrEqual) { | ||
const left = generateExpression(greaterThanOrEqual.leftHand); | ||
const right = generateExpression(greaterThanOrEqual.rightHand); | ||
const left = generateExpression(greaterThanOrEqual.left); | ||
const right = generateExpression(greaterThanOrEqual.right); | ||
return `${left} >= ${right}`; | ||
@@ -289,0 +293,0 @@ } |
@@ -23,2 +23,3 @@ import { Result } from "@eeue56/ts-core/build/main/lib/result"; | ||
export declare function exportPackage(package_: Package): string; | ||
export declare function loadPackageFile(path: string): Promise<Result<string, Package>>; | ||
export declare function decodePackage(potentialPackage: any): Result<string, Package>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodePackage = exports.exportPackage = exports.addDependency = exports.Package = exports.dependenciesFromRecord = exports.Dependency = exports.PackageModule = void 0; | ||
exports.decodePackage = exports.loadPackageFile = exports.exportPackage = exports.addDependency = exports.Package = exports.dependenciesFromRecord = exports.Dependency = exports.PackageModule = void 0; | ||
const adeilad_1 = require("@eeue56/adeilad"); | ||
const promises_1 = require("fs/promises"); | ||
function PackageModule(name) { | ||
@@ -65,2 +66,6 @@ return { | ||
exports.exportPackage = exportPackage; | ||
async function loadPackageFile(path) { | ||
return decodePackage(JSON.parse(await (await promises_1.readFile(path)).toString())); | ||
} | ||
exports.loadPackageFile = loadPackageFile; | ||
function decodePackage(potentialPackage) { | ||
@@ -67,0 +72,0 @@ return adeilad_1.decode(packageDecoder, potentialPackage); |
import { Result } from "@eeue56/ts-core/build/main/lib/result"; | ||
import { Token } from "./tokens"; | ||
import { Block, Expression, Module, UnparsedBlock } from "./types"; | ||
import { Block, ContextModule, Expression, Module, UnparsedBlock } from "./types"; | ||
export declare function parseExpression(body: string): Result<string, Expression>; | ||
@@ -8,1 +8,3 @@ export declare function parseBlock(block: UnparsedBlock): Result<string, Block>; | ||
export declare function parse(body: string, filename?: string): Module; | ||
export declare function addTypeErrors(module: ContextModule, otherModules: ContextModule[]): ContextModule; | ||
export declare function parseWithContext(body: string, filename?: string): ContextModule; |
@@ -327,2 +327,7 @@ "use strict"; | ||
} | ||
case "}": { | ||
tokens.push(CloseCurlyBracesToken()); | ||
currentToken = ""; | ||
break; | ||
} | ||
default: { | ||
@@ -329,0 +334,0 @@ state = Keyword(); |
@@ -80,11 +80,15 @@ "use strict"; | ||
const generatedProperties = syntax.properties.map(generateProperty); | ||
const properties = generatedProperties.join(";\n ") + ";"; | ||
const properties = generatedProperties.length === 0 | ||
? "" | ||
: " " + generatedProperties.join(";\n ") + ";"; | ||
const type = generateType(syntax.type); | ||
const args = generatedProperties.join(", "); | ||
const args = generatedProperties.length === 0 | ||
? " " | ||
: " " + generatedProperties.join(", ") + " "; | ||
return ` | ||
type ${type} = { | ||
${properties} | ||
${properties} | ||
} | ||
function ${type}(args: { ${args} }): ${type} { | ||
function ${type}(args: {${args}}): ${type} { | ||
return { | ||
@@ -104,2 +108,4 @@ ...args, | ||
function generateObjectLiteral(literal) { | ||
if (literal.fields.length === 0) | ||
return `{ }`; | ||
let fields = literal.fields.map(generateField).join(",\n "); | ||
@@ -163,2 +169,4 @@ if (literal.fields.length === 1) | ||
function generateBranch(predicate, branch) { | ||
const body = generateExpression(branch.body); | ||
const returnWrapper = types_1.isSimpleValue(branch.body.kind) ? "return " : ""; | ||
switch (branch.pattern.kind) { | ||
@@ -170,3 +178,3 @@ case "Destructure": { | ||
return `case "${branch.pattern.constructor}": {${pattern} | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -176,3 +184,3 @@ } | ||
return `case "${branch.pattern.body}": { | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -182,3 +190,3 @@ } | ||
return `default: { | ||
return ${generateExpression(branch.body)}; | ||
${returnWrapper}${body}; | ||
}`; | ||
@@ -386,29 +394,29 @@ } | ||
function generateEquality(equality) { | ||
const left = generateExpression(equality.leftHand); | ||
const right = generateExpression(equality.rightHand); | ||
const left = generateExpression(equality.left); | ||
const right = generateExpression(equality.right); | ||
return `${left} === ${right}`; | ||
} | ||
function generateInEquality(inEquality) { | ||
const left = generateExpression(inEquality.leftHand); | ||
const right = generateExpression(inEquality.rightHand); | ||
const left = generateExpression(inEquality.left); | ||
const right = generateExpression(inEquality.right); | ||
return `${left} !== ${right}`; | ||
} | ||
function generateLessThan(lessThan) { | ||
const left = generateExpression(lessThan.leftHand); | ||
const right = generateExpression(lessThan.rightHand); | ||
const left = generateExpression(lessThan.left); | ||
const right = generateExpression(lessThan.right); | ||
return `${left} < ${right}`; | ||
} | ||
function generateLessThanOrEqual(lessThanOrEqual) { | ||
const left = generateExpression(lessThanOrEqual.leftHand); | ||
const right = generateExpression(lessThanOrEqual.rightHand); | ||
const left = generateExpression(lessThanOrEqual.left); | ||
const right = generateExpression(lessThanOrEqual.right); | ||
return `${left} <= ${right}`; | ||
} | ||
function generateGreaterThan(greaterThan) { | ||
const left = generateExpression(greaterThan.leftHand); | ||
const right = generateExpression(greaterThan.rightHand); | ||
const left = generateExpression(greaterThan.left); | ||
const right = generateExpression(greaterThan.right); | ||
return `${left} > ${right}`; | ||
} | ||
function generateGreaterThanOrEqual(greaterThanOrEqual) { | ||
const left = generateExpression(greaterThanOrEqual.leftHand); | ||
const right = generateExpression(greaterThanOrEqual.rightHand); | ||
const left = generateExpression(greaterThanOrEqual.left); | ||
const right = generateExpression(greaterThanOrEqual.right); | ||
return `${left} >= ${right}`; | ||
@@ -415,0 +423,0 @@ } |
import { Result } from "@eeue56/ts-core/build/main/lib/result"; | ||
import { Block, Expression, Import, Type, TypedBlock } from "./types"; | ||
export declare function isSameType(first: Type, second: Type, topLevel: boolean): boolean; | ||
export declare function inferType(expression: Expression): Type; | ||
export declare function inferType(expression: Expression, typedBlocks: TypedBlock[]): Result<string, Type>; | ||
export declare function validateType(block: Block, typedBlocks: TypedBlock[], imports: Import[]): Result<string, Type>; |
@@ -10,3 +10,5 @@ "use strict"; | ||
return true; | ||
return first.name === second.name; | ||
// todo: figure this out | ||
//return first.name === second.name; | ||
return true; | ||
} | ||
@@ -114,11 +116,14 @@ function isSameFixedType(first, second, topLevel) { | ||
} | ||
function inferListValue(value) { | ||
function inferListValue(value, typedBlocks) { | ||
if (value.items.length === 0) | ||
return types_1.FixedType("List", [types_1.FixedType("any", [])]); | ||
return result_1.Ok(types_1.FixedType("List", [types_1.FixedType("any", [])])); | ||
let types = []; | ||
value.items.forEach((item) => { | ||
types.push(inferType(item)); | ||
}); | ||
for (const item of value.items) { | ||
const inferred = inferType(item, typedBlocks); | ||
if (inferred.kind === "err") | ||
return inferred; | ||
types.push(inferred.value); | ||
} | ||
const uniqueTypes = reduceTypes(types); | ||
return types_1.FixedType("List", uniqueTypes); | ||
return result_1.Ok(types_1.FixedType("List", uniqueTypes)); | ||
} | ||
@@ -131,56 +136,83 @@ function inferListRange(value) { | ||
} | ||
function inferIfStatement(value) { | ||
const ifBranch = inferType(value.ifBody); | ||
const elseBranch = inferType(value.elseBody); | ||
if (isSameType(ifBranch, elseBranch, false)) | ||
function inferIfStatement(value, typedBlocks) { | ||
const ifBranch = inferType(value.ifBody, typedBlocks); | ||
const elseBranch = inferType(value.elseBody, typedBlocks); | ||
if (ifBranch.kind === "err") | ||
return ifBranch; | ||
return types_1.FixedType("any", []); | ||
if (elseBranch.kind === "err") | ||
return elseBranch; | ||
if (isSameType(ifBranch.value, elseBranch.value, false)) | ||
return result_1.Ok(ifBranch.value); | ||
return result_1.Err(`Conflicting types: ${typeToString(ifBranch.value)}, ${typeToString(elseBranch.value)}`); | ||
} | ||
function inferBranch(value) { | ||
return inferType(value.body); | ||
function inferBranch(value, typedBlocks) { | ||
return inferType(value.body, typedBlocks); | ||
} | ||
function inferCaseStatement(value) { | ||
const branches = reduceTypes(value.branches.map(inferBranch)); | ||
function inferCaseStatement(value, typedBlocks) { | ||
const typesToReduce = []; | ||
for (const branch of value.branches) { | ||
const inf = inferBranch(branch, typedBlocks); | ||
if (inf.kind === "err") | ||
return inf; | ||
typesToReduce.push(inf.value); | ||
} | ||
const branches = reduceTypes(typesToReduce); | ||
if (branches.length === 1) | ||
return branches[0]; | ||
return types_1.FixedType("any", []); | ||
return result_1.Ok(branches[0]); | ||
return result_1.Err(`Conflicting types: ${branches.map(typeToString).join(", ")}`); | ||
} | ||
function inferAddition(value) { | ||
const left = inferType(value.left); | ||
const right = inferType(value.right); | ||
if (!isSameType(left, right, false)) | ||
return types_1.FixedType("any", []); | ||
function inferAddition(value, typedBlocks) { | ||
const left = inferType(value.left, typedBlocks); | ||
const right = inferType(value.right, typedBlocks); | ||
if (left.kind === "err") | ||
return left; | ||
if (right.kind === "err") | ||
return right; | ||
if (!isSameType(left.value, right.value, false)) | ||
return result_1.Err(`Mismatching types between ${typeToString(left.value)} and ${typeToString(right.value)}`); | ||
return left; | ||
} | ||
function inferSubtraction(value) { | ||
const left = inferType(value.left); | ||
const right = inferType(value.right); | ||
if (!isSameType(left, right, false)) | ||
return types_1.FixedType("any", []); | ||
function inferSubtraction(value, typedBlocks) { | ||
const left = inferType(value.left, typedBlocks); | ||
const right = inferType(value.right, typedBlocks); | ||
if (left.kind === "err") | ||
return left; | ||
if (right.kind === "err") | ||
return right; | ||
if (!isSameType(left.value, right.value, false)) | ||
return result_1.Err(`Mismatching types between ${typeToString(left.value)} and ${typeToString(right.value)}`); | ||
return left; | ||
} | ||
function inferMultiplication(value) { | ||
const left = inferType(value.left); | ||
const right = inferType(value.right); | ||
if (!isSameType(left, right, false)) | ||
return types_1.FixedType("any", []); | ||
function inferMultiplication(value, typedBlocks) { | ||
const left = inferType(value.left, typedBlocks); | ||
const right = inferType(value.right, typedBlocks); | ||
if (left.kind === "err") | ||
return left; | ||
if (right.kind === "err") | ||
return right; | ||
if (!isSameType(left.value, right.value, false)) | ||
return result_1.Err(`Mismatching types between ${typeToString(left.value)} and ${typeToString(right.value)}`); | ||
return left; | ||
} | ||
function inferDivision(value) { | ||
const left = inferType(value.left); | ||
const right = inferType(value.right); | ||
if (!isSameType(left, right, false)) | ||
return types_1.FixedType("any", []); | ||
function inferDivision(value, typedBlocks) { | ||
const left = inferType(value.left, typedBlocks); | ||
const right = inferType(value.right, typedBlocks); | ||
if (left.kind === "err") | ||
return left; | ||
if (right.kind === "err") | ||
return right; | ||
if (!isSameType(left.value, right.value, false)) | ||
return result_1.Err(`Mismatching types between ${typeToString(left.value)} and ${typeToString(right.value)}`); | ||
return left; | ||
} | ||
function inferLeftPipe(value) { | ||
const right = inferType(value.right); | ||
function inferLeftPipe(value, typedBlocks) { | ||
const right = inferType(value.right, typedBlocks); | ||
return right; | ||
} | ||
function inferRightPipe(value) { | ||
const left = inferType(value.left); | ||
function inferRightPipe(value, typedBlocks) { | ||
const left = inferType(value.left, typedBlocks); | ||
return left; | ||
} | ||
function inferModuleReference(value) { | ||
return inferType(value.value); | ||
function inferModuleReference(value, typedBlocks) { | ||
return inferType(value.value, typedBlocks); | ||
} | ||
@@ -196,3 +228,12 @@ function inferFunctionCall(value) { | ||
} | ||
function inferConstructor(value) { | ||
function inferConstructor(value, typedBlocks) { | ||
for (const block of typedBlocks) { | ||
if (block.kind === "UnionType") { | ||
for (const tag of block.tags) { | ||
if (value.constructor === tag.name) { | ||
return block.type; | ||
} | ||
} | ||
} | ||
} | ||
return types_1.FixedType("any", []); | ||
@@ -224,58 +265,58 @@ } | ||
} | ||
function inferType(expression) { | ||
function inferType(expression, typedBlocks) { | ||
switch (expression.kind) { | ||
case "Value": | ||
return inferValue(expression); | ||
return result_1.Ok(inferValue(expression)); | ||
case "StringValue": | ||
return inferStringValue(expression); | ||
return result_1.Ok(inferStringValue(expression)); | ||
case "FormatStringValue": | ||
return inferFormatStringValue(expression); | ||
return result_1.Ok(inferFormatStringValue(expression)); | ||
case "ListValue": | ||
return inferListValue(expression); | ||
return inferListValue(expression, typedBlocks); | ||
case "ListRange": | ||
return inferListRange(expression); | ||
return result_1.Ok(inferListRange(expression)); | ||
case "ObjectLiteral": | ||
return inferObjectLiteral(expression); | ||
return result_1.Ok(inferObjectLiteral(expression)); | ||
case "IfStatement": | ||
return inferIfStatement(expression); | ||
return inferIfStatement(expression, typedBlocks); | ||
case "CaseStatement": | ||
return inferCaseStatement(expression); | ||
return inferCaseStatement(expression, typedBlocks); | ||
case "Addition": | ||
return inferAddition(expression); | ||
return inferAddition(expression, typedBlocks); | ||
case "Subtraction": | ||
return inferSubtraction(expression); | ||
return inferSubtraction(expression, typedBlocks); | ||
case "Multiplication": | ||
return inferMultiplication(expression); | ||
return inferMultiplication(expression, typedBlocks); | ||
case "Division": | ||
return inferDivision(expression); | ||
return inferDivision(expression, typedBlocks); | ||
case "And": | ||
return inferAnd(expression); | ||
return result_1.Ok(inferAnd(expression)); | ||
case "Or": | ||
return inferOr(expression); | ||
return result_1.Ok(inferOr(expression)); | ||
case "LeftPipe": | ||
return inferLeftPipe(expression); | ||
return inferLeftPipe(expression, typedBlocks); | ||
case "RightPipe": | ||
return inferRightPipe(expression); | ||
return inferRightPipe(expression, typedBlocks); | ||
case "ModuleReference": | ||
return inferModuleReference(expression); | ||
return inferModuleReference(expression, typedBlocks); | ||
case "FunctionCall": | ||
return inferFunctionCall(expression); | ||
return result_1.Ok(inferFunctionCall(expression)); | ||
case "Lambda": | ||
return inferLambda(expression); | ||
return result_1.Ok(inferLambda(expression)); | ||
case "LambdaCall": | ||
return inferLambdaCall(expression); | ||
return result_1.Ok(inferLambdaCall(expression)); | ||
case "Constructor": | ||
return inferConstructor(expression); | ||
return result_1.Ok(inferConstructor(expression, typedBlocks)); | ||
case "Equality": | ||
return inferEquality(expression); | ||
return result_1.Ok(inferEquality(expression)); | ||
case "InEquality": | ||
return inferInEquality(expression); | ||
return result_1.Ok(inferInEquality(expression)); | ||
case "LessThan": | ||
return inferLessThan(expression); | ||
return result_1.Ok(inferLessThan(expression)); | ||
case "LessThanOrEqual": | ||
return inferLessThanOrEqual(expression); | ||
return result_1.Ok(inferLessThanOrEqual(expression)); | ||
case "GreaterThan": | ||
return inferGreaterThan(expression); | ||
return result_1.Ok(inferGreaterThan(expression)); | ||
case "GreaterThanOrEqual": | ||
return inferGreaterThanOrEqual(expression); | ||
return result_1.Ok(inferGreaterThanOrEqual(expression)); | ||
} | ||
@@ -329,3 +370,6 @@ } | ||
} | ||
const inferred = inferType(block.value); | ||
const inferredRes = inferType(block.value, typedBlocks); | ||
if (inferredRes.kind === "err") | ||
return inferredRes; | ||
const inferred = inferredRes.value; | ||
if (isSameType(block.type, inferred, false)) { | ||
@@ -340,3 +384,6 @@ return result_1.Ok(block.type); | ||
} | ||
const inferred = inferType(block.body); | ||
const inferredRes = inferType(block.body, typedBlocks); | ||
if (inferredRes.kind === "err") | ||
return inferredRes; | ||
const inferred = inferredRes.value; | ||
if (isSameType(block.returnType, inferred, false)) { | ||
@@ -343,0 +390,0 @@ return result_1.Ok(block.returnType); |
@@ -209,36 +209,36 @@ import { Maybe } from "@eeue56/ts-core/build/main/lib/maybe"; | ||
kind: "Equality"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function Equality(leftHand: Expression, rightHand: Expression): Equality; | ||
export declare function Equality(left: Expression, right: Expression): Equality; | ||
export declare type InEquality = { | ||
kind: "InEquality"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function InEquality(leftHand: Expression, rightHand: Expression): InEquality; | ||
export declare function InEquality(left: Expression, right: Expression): InEquality; | ||
export declare type LessThan = { | ||
kind: "LessThan"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function LessThan(leftHand: Expression, rightHand: Expression): LessThan; | ||
export declare function LessThan(left: Expression, right: Expression): LessThan; | ||
export declare type LessThanOrEqual = { | ||
kind: "LessThanOrEqual"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function LessThanOrEqual(leftHand: Expression, rightHand: Expression): LessThanOrEqual; | ||
export declare function LessThanOrEqual(left: Expression, right: Expression): LessThanOrEqual; | ||
export declare type GreaterThan = { | ||
kind: "GreaterThan"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function GreaterThan(leftHand: Expression, rightHand: Expression): GreaterThan; | ||
export declare function GreaterThan(left: Expression, right: Expression): GreaterThan; | ||
export declare type GreaterThanOrEqual = { | ||
kind: "GreaterThanOrEqual"; | ||
leftHand: Expression; | ||
rightHand: Expression; | ||
left: Expression; | ||
right: Expression; | ||
}; | ||
export declare function GreaterThanOrEqual(leftHand: Expression, rightHand: Expression): GreaterThanOrEqual; | ||
export declare function GreaterThanOrEqual(left: Expression, right: Expression): GreaterThanOrEqual; | ||
export declare type Expression = IfStatement | CaseStatement | Addition | Subtraction | Multiplication | Division | And | Or | LeftPipe | RightPipe | ModuleReference | FunctionCall | Lambda | LambdaCall | Constructor | StringValue | FormatStringValue | ListValue | ListRange | Equality | InEquality | LessThan | LessThanOrEqual | GreaterThan | GreaterThanOrEqual | ObjectLiteral | Value; | ||
@@ -309,1 +309,10 @@ export declare type SimpleValue = "StringValue" | "FormatStringValue" | "ListValue" | "ListRange" | "Value" | "Addition" | "Subtraction" | "Multiplication" | "Division" | "Lambda" | "Equality" | "InEquality" | "LessThan" | "LessThanOrEqual" | "GreaterThan" | "GreaterThanOrEqual" | "And" | "Or" | "ModuleReference" | "FunctionCall" | "LeftPipe" | "ObjectLiteral" | "Constructor"; | ||
export declare function Module(name: string, body: Block[], errors: string[]): Module; | ||
export declare type ContextModule = { | ||
kind: "ContextModule"; | ||
name: string; | ||
body: Block[]; | ||
unparsedBody: UnparsedBlock[]; | ||
errors: string[]; | ||
}; | ||
export declare function ContextModule(name: string, body: Block[], unparsedBody: UnparsedBlock[], errors: string[]): ContextModule; | ||
export declare function contextModuleToModule(module: ContextModule): Module; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MultilineComment = exports.Comment = exports.Export = exports.Import = exports.ImportModule = exports.Const = exports.Function = exports.isLeftPipeableExpression = exports.isSimpleValue = exports.GreaterThanOrEqual = exports.GreaterThan = exports.LessThanOrEqual = exports.LessThan = exports.InEquality = exports.Equality = exports.CaseStatement = exports.Branch = exports.Default = exports.LambdaCall = exports.Lambda = exports.FunctionCall = exports.ModuleReference = exports.RightPipe = exports.LeftPipe = exports.Or = exports.And = exports.Division = exports.Multiplication = exports.Subtraction = exports.Addition = exports.IfStatement = exports.Constructor = exports.Destructure = exports.FormatStringValue = exports.ListRange = exports.ListValue = exports.StringValue = exports.ObjectLiteral = exports.Field = exports.Value = exports.AnonFunctionArg = exports.FunctionArg = exports.TypeAlias = exports.Property = exports.UnionType = exports.Tag = exports.TagArg = exports.FunctionType = exports.FixedType = exports.GenericType = void 0; | ||
exports.Module = exports.UnparsedBlock = void 0; | ||
exports.contextModuleToModule = exports.ContextModule = exports.Module = exports.UnparsedBlock = void 0; | ||
function GenericType(name) { | ||
@@ -277,47 +277,47 @@ return { | ||
exports.CaseStatement = CaseStatement; | ||
function Equality(leftHand, rightHand) { | ||
function Equality(left, right) { | ||
return { | ||
kind: "Equality", | ||
leftHand, | ||
rightHand, | ||
left: left, | ||
right, | ||
}; | ||
} | ||
exports.Equality = Equality; | ||
function InEquality(leftHand, rightHand) { | ||
function InEquality(left, right) { | ||
return { | ||
kind: "InEquality", | ||
leftHand, | ||
rightHand, | ||
left, | ||
right, | ||
}; | ||
} | ||
exports.InEquality = InEquality; | ||
function LessThan(leftHand, rightHand) { | ||
function LessThan(left, right) { | ||
return { | ||
kind: "LessThan", | ||
leftHand, | ||
rightHand, | ||
left, | ||
right, | ||
}; | ||
} | ||
exports.LessThan = LessThan; | ||
function LessThanOrEqual(leftHand, rightHand) { | ||
function LessThanOrEqual(left, right) { | ||
return { | ||
kind: "LessThanOrEqual", | ||
leftHand, | ||
rightHand, | ||
left, | ||
right, | ||
}; | ||
} | ||
exports.LessThanOrEqual = LessThanOrEqual; | ||
function GreaterThan(leftHand, rightHand) { | ||
function GreaterThan(left, right) { | ||
return { | ||
kind: "GreaterThan", | ||
leftHand, | ||
rightHand, | ||
left, | ||
right, | ||
}; | ||
} | ||
exports.GreaterThan = GreaterThan; | ||
function GreaterThanOrEqual(leftHand, rightHand) { | ||
function GreaterThanOrEqual(left, right) { | ||
return { | ||
kind: "GreaterThanOrEqual", | ||
leftHand, | ||
rightHand, | ||
left, | ||
right, | ||
}; | ||
@@ -437,1 +437,15 @@ } | ||
exports.Module = Module; | ||
function ContextModule(name, body, unparsedBody, errors) { | ||
return { | ||
kind: "ContextModule", | ||
name, | ||
body, | ||
unparsedBody, | ||
errors, | ||
}; | ||
} | ||
exports.ContextModule = ContextModule; | ||
function contextModuleToModule(module) { | ||
return Module(module.name, module.body, module.errors); | ||
} | ||
exports.contextModuleToModule = contextModuleToModule; |
{ | ||
"name": "derw", | ||
"version": "0.0.3-9", | ||
"version": "0.0.3-10", | ||
"description": "An Elm-inspired language that transpiles to TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -285,3 +285,5 @@ import { | ||
for (const import_ of imports) { | ||
const fileWithDerwExtension = import_ + `.derw`; | ||
const fileWithDerwExtension = import_.endsWith(".derw") | ||
? import_ | ||
: import_ + `.derw`; | ||
const isDerw = await fileExists(fileWithDerwExtension); | ||
@@ -288,0 +290,0 @@ |
Sorry, the diff of this file is too big to display
534554
83
15745
7