ca657b5b06
* refactor: compile with esmoudle interop * Rigidify code replacement by using Lodash templates. * Generate zip file bundle. * Use yarn's fslib to implement the fake filesystem. Leverage the work done by yarn, rather than reimplementing from scratch. This means the fake fs is now reading from a zip file in the binary. A few methods need custom implementations as the fake fs is not writable. These were copied and adjusted from the yarn ZipOpenFS. * Add test suite using the built artefact. Smoke tests the different fs methods. Not perfect in any world, but better than nothing. * Fix tsc on Windows - globbing doesn't work there. There's probably a cleaner way to do this... * Bump version. * Dep bumps. * fixup 9d57b32: make fs patch code clearer. * fixup 3771c720: simplify test to just use require directly. --------- Co-authored-by: calebboyd <caleb.boyd@gmail.com>
26 lines
866 B
TypeScript
26 lines
866 B
TypeScript
import { each } from '../util'
|
|
import globs from 'globby'
|
|
import { resolve } from 'path'
|
|
import { NexeCompiler } from '../compiler'
|
|
|
|
export default async function resource(compiler: NexeCompiler, next: () => Promise<any>) {
|
|
const { cwd, resources } = compiler.options
|
|
if (!resources.length) {
|
|
return next()
|
|
}
|
|
const step = compiler.log.step('Bundling Resources...')
|
|
let count = 0
|
|
|
|
// workaround for https://github.com/sindresorhus/globby/issues/127
|
|
// and https://github.com/mrmlnc/fast-glob#pattern-syntax
|
|
const resourcesWithForwardSlashes = resources.map((r) => r.replace(/\\/g, '/'))
|
|
|
|
await each(globs(resourcesWithForwardSlashes, { cwd, onlyFiles: true }), async (file) => {
|
|
count++
|
|
step.log(`Including file: ${file}`)
|
|
await compiler.addResource(resolve(cwd, file))
|
|
})
|
|
step.log(`Included ${count} file(s)`)
|
|
return next()
|
|
}
|