File exit.patch of Package local-npm-registry
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
new file mode 100644
index 0000000..7b75470
--- /dev/null
+++ b/.github/workflows/tests.yaml
@@ -0,0 +1,18 @@
+name: Unit tests
+on: [push, pull_request]
+jobs:
+ containers-tests-job:
+ runs-on: ubuntu:latest
+ container:
+ image: registry.opensuse.org/opensuse/bci/nodejs:latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install deps and run unit tests
+ run: |
+ echo "Job started by ${{ github.event_name }}"
+ echo "Running on ${{ runner.os }}"
+ echo "Sources checked out"
+ echo "Fetching deps"
+ npm ci
+ npm run test
+
diff --git a/src/index.ts b/src/index.ts
index 0a369cc..dc699df 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -100,28 +100,36 @@ function runNpmInstall(): Promise<void> {
function printHelpInformation() {
console.log(" usage: index [ npm files | npm tarball directories ] ... [npm run options] ");
console.log("--help prints this help message");
+ console.log("--debug starts service and listens on localhost until killed")
}
-function mainEntryFunction(): Promise<void> {
+function mainEntryFunction(): Promise<any> {
if (argv.includes("--help")) {
printHelpInformation();
return;
}
+ const isDebug = argv.includes("--debug")
+
const registry = new Registry();
registry.addBackend(new TarballRegistryBackend);
registry.addBackend(new DirRegistryBackend);
const service = new Service({url: new URL("http://localhost")});
registry.serviceProvider = service;
- return registerTarballsFromCommandline(registry)
+ const s = registerTarballsFromCommandline(registry)
.then(() => setupServerAndGetPort(service, registry))
- .then(port => configureNpmToSpecificLocalhostPort(service, port))
+
+ if (isDebug)
+ return
+
+ return s.then(port => configureNpmToSpecificLocalhostPort(service, port))
.then(() => runNpmInstall())
.then(() => {
console.log("npm done. Shutting down proxy");
})
.catch(msg => {
+ process.exitCode = 1
console.log("An error occurred: " + msg);
})
.finally(() => {