diff --git a/scripts/prepare.ts b/scripts/prepare.ts index 014f4c3b2..69bc51eb6 100644 --- a/scripts/prepare.ts +++ b/scripts/prepare.ts @@ -60,7 +60,7 @@ import { consoleLogger } from '../src/logger'; console.log('Processing ' + p.path + r); let c: FuncCompilationResult; try { - let stdlibPath = path.resolve(__dirname, '../src/stdlib/stdlib.fc'); + let stdlibPath = path.resolve(__dirname, '..', 'stdlib', 'stdlib.fc'); let stdlib = fs.readFileSync(stdlibPath, 'utf-8'); let code = fs.readFileSync(p.path + r, 'utf-8'); c = await funcCompile({ @@ -78,6 +78,7 @@ import { consoleLogger } from '../src/logger'; continue; } } catch (e) { + console.warn(e); console.warn('Failed'); continue; } diff --git a/src/node.ts b/src/node.ts index d2f25cbce..465f2d1f6 100644 --- a/src/node.ts +++ b/src/node.ts @@ -46,7 +46,7 @@ export async function run(args: { configPath: string, projectNames?: string[] }) // Compile let success = true; let project = createNodeFileSystem(rootPath, false); - let stdlib = path.resolve(__dirname, '..', 'stdlib') + path.sep; // Improves developer experience + let stdlib = createNodeFileSystem(path.resolve(__dirname, '..', 'stdlib'), false); // Improves developer experience for (let config of projects) { console.log('💼 Compiling project ' + config.name + '...'); let built = await build({ config, project, stdlib, logger: consoleLogger }); diff --git a/src/pipeline/build.ts b/src/pipeline/build.ts index 7e69f0c92..08d9c2c23 100644 --- a/src/pipeline/build.ts +++ b/src/pipeline/build.ts @@ -23,12 +23,12 @@ const version = require('../../package.json').version; export async function build(args: { config: ConfigProject, project: VirtualFileSystem, - stdlib: string, + stdlib: string | VirtualFileSystem, logger?: TactLogger | null | undefined }) { const { config, project } = args; - const stdlib = createVirtualFileSystem(args.stdlib, files); + const stdlib = (typeof args.stdlib === 'string') ? createVirtualFileSystem(args.stdlib, files) : args.stdlib; const logger: TactLogger = args.logger || consoleLogger; // Configure context diff --git a/src/vfs/createVirtualFileSystem.ts b/src/vfs/createVirtualFileSystem.ts index e6c57dd4d..eba86deeb 100644 --- a/src/vfs/createVirtualFileSystem.ts +++ b/src/vfs/createVirtualFileSystem.ts @@ -3,6 +3,9 @@ import { VirtualFileSystem } from "./VirtualFileSystem"; export function createVirtualFileSystem(root: string, fs: { [key: string]: string }, readonly: boolean = true): VirtualFileSystem { let normalizedRoot = normalize(root); + if (!normalizedRoot.endsWith('/')) { + normalizedRoot += '/'; + } return { root: normalizedRoot, exists(filePath: string): boolean {