Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ dist/
!.env.example

# something is generating this file :shrug:
integration-test.json
integration-test.json

package-lock.json
40 changes: 21 additions & 19 deletions bin/harperdb.js → bin/harper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ upgrade - Upgrade harperdb
version - Print the version
`;

async function harperdb() {
async function harper() {
let nodeResults = checkNode();

if (nodeResults) {
Expand Down Expand Up @@ -123,21 +123,23 @@ async function harperdb() {
return HELP;
}
}

harperdb()
.then((message) => {
if (message) {
console.log(message);
logger.notify(message);
}
// Intentionally not calling `process.exit(0);` so if a CLI
// command resulted in a long running process (aka `run`),
// it continues to run.
})
.catch((error) => {
if (error) {
console.error(error);
logger.error(error);
}
process.exit(1);
});
exports.harper = harper;
if (require.main === module) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure why this is necessary. Components should not be importing anything in the bin directory.

harper()
.then((message) => {
if (message) {
console.log(message);
logger.notify(message);
}
// Intentionally not calling `process.exit(0);` so if a CLI
// command resulted in a long running process (aka `run`),
// it continues to run.
})
.catch((error) => {
if (error) {
console.error(error);
logger.error(error);
}
process.exit(1);
});
}
10 changes: 10 additions & 0 deletions components/componentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Status } from '../server/status/index.ts';
import { lifecycle as componentLifecycle } from './status/index.ts';
import { DEFAULT_CONFIG } from './DEFAULT_CONFIG.ts';
import { PluginModule } from './PluginModule.ts';
import { platform } from 'node:os';

const CF_ROUTES_DIR = resolvePath(env.get(CONFIG_PARAMS.COMPONENTSROOT));
let loadedComponents = new Map<any, any>();
Expand Down Expand Up @@ -96,6 +97,15 @@ const TRUSTED_RESOURCE_LOADERS = {
*/
};

if (process.env.HARPER_BUILTIN_COMPONENTS) {
const separator = platform() === 'win32' ? ';' : ':';
for (const componentDefinition of process.env.HARPER_BUILTIN_COMPONENTS.split(separator)) {
const [componentName, moduleId] = componentDefinition.trim().split('=');
if (!componentDefinition) continue;
TRUSTED_RESOURCE_LOADERS[componentName] = require(moduleId);
}
}

const portsStarted = [];
const loadedPaths = new Map();
let errorReporter;
Expand Down
Loading
Loading