@eslang/es-npm
Version:
A command line tool to create npm compatible Espresso script packages.
25 lines (22 loc) • 607 B
JavaScript
/**
* all native modules must be explicitly exposed to Espresso script.
*/
function copy (source, exporting) {
// In real world, native members can be filtered before exporting.
Object.assign(exporting, source)
return true
}
module.exports = function (uri) {
switch (uri) {
case 'fs':
return copy.bind(null, require('fs'))
case 'path':
return copy.bind(null, require('path'))
case 'shelljs':
return copy.bind(null, require('shelljs'))
default:
console.warn('Espresso script is requesting for an unknown module:', uri)
return null
}
}