UNPKG

@sap/cds-dk

Version:

Command line client and development toolkit for the SAP Cloud Application Programming Model

24 lines (21 loc) 791 B
/** @type { import('@sap/cds/lib') } */ const cds = _local ('@sap/cds') /** @type { import('@sap/cds/lib') & {_local: (id: string) => any} } */ module.exports = Object.defineProperties (cds, { // for internal use in cds-dk only _log: { value: _local ('../bin/util/log'), configurable: true }, _local: { value: _local, configurable: true }, _localOrGlobal: { value: id => _local(id, _npmRoot()), configurable: true }, }) function _local (id, ...morePaths) { return require(require.resolve (id, {paths:[ process.cwd(), // project-local module is preferred __dirname, // otherwise from our own dependencies ...morePaths ]})) } function _npmRoot() { try { return require ('child_process').execSync('npm root -g').toString().trim() } catch { return '' } }