From 0102ef6686559388c6e4dbc068c2ad4001bed0e9 Mon Sep 17 00:00:00 2001 From: George Cook Date: Tue, 13 Oct 2020 22:18:45 -0500 Subject: [PATCH] =?UTF-8?q?Allows=20transpilation=20of=20files=20that=20do?= =?UTF-8?q?=20not=20come=20from=20roku=20deploy's=20fil=E2=80=A6=20(#212)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allows transpilation of files that do not come from roku deploy's file entries, so generated files can be included in the build output * fix eslint errors. add bsc protocol to src path for in-memory files * Add unit tests for in-memory transpile Co-authored-by: Bronley Plumb --- src/Program.spec.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/Program.ts | 9 +++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/Program.spec.ts b/src/Program.spec.ts index d9b30d612..3b3b6daeb 100644 --- a/src/Program.spec.ts +++ b/src/Program.spec.ts @@ -1319,6 +1319,55 @@ describe('Program', () => { }); describe('transpile', () => { + it('transpiles in-memory-only files', async () => { + await program.addOrReplaceFile('source/logger.bs', ` + sub logInfo() + print SOURCE_LINE_NUM + end sub + `); + await program.transpile([], program.options.stagingFolderPath); + expect( + fsExtra.readFileSync(s`${stagingFolderPath}/source/logger.brs`).toString().split(/\r?\n/).map(x => x.trim()) + ).to.eql([ + 'sub logInfo()', + 'print 3', + 'end sub' + ]); + }); + + it('copies in-memory-only .brs files to stagingDir', async () => { + await program.addOrReplaceFile('source/logger.brs', ` + sub logInfo() + print "logInfo" + end sub + `); + await program.transpile([], program.options.stagingFolderPath); + expect( + fsExtra.readFileSync(s`${stagingFolderPath}/source/logger.brs`).toString() + ).to.eql(` + sub logInfo() + print "logInfo" + end sub + `); + }); + + it('copies in-memory .xml file', async () => { + await program.addOrReplaceFile('components/Component1.xml', ` + + + + `); + await program.transpile([], program.options.stagingFolderPath); + expect( + fsExtra.readFileSync(s`${stagingFolderPath}/components/Component1.xml`).toString() + ).to.eql(` + + +