mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-20 01:25:31 -05:00
Skip update check when running in Docker
This commit is contained in:
@@ -34,7 +34,7 @@ build-docker:
|
||||
- |
|
||||
[ "$GH_REGISTRY_IMAGE" != "" ] && docker login -u "$GH_REGISTRY_USER" -p "$GH_REGISTRY_PASSWORD" "$GH_REGISTRY"
|
||||
script:
|
||||
- node resources/build/ci-package-json.js
|
||||
- node resources/build/ci-package-json.js docker "$CI_REGISTRY_IMAGE:ref-$CI_COMMIT_REF_SLUG"
|
||||
|
||||
- docker build --pull --no-cache --tag "$CI_REGISTRY_IMAGE:ref-$CI_COMMIT_REF_SLUG" .
|
||||
- |
|
||||
|
||||
@@ -32,6 +32,10 @@ if (process.argv[2] === 'github') {
|
||||
pkg.version = process.env.VERSION || pkg.version;
|
||||
pkg.__nxapi_release = process.env.CI_COMMIT_TAG;
|
||||
|
||||
if (process.argv[2] === 'docker') {
|
||||
pkg.__nxapi_docker = process.argv[3];
|
||||
}
|
||||
|
||||
pkg.__nxapi_git = pkg.__nxapi_git ?? {
|
||||
revision,
|
||||
branch: branch && branch !== 'HEAD' ? branch : null,
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as fs from 'node:fs/promises';
|
||||
import fetch from 'node-fetch';
|
||||
import createDebug from 'debug';
|
||||
import mkdirp from 'mkdirp';
|
||||
import { dir, version } from '../util/product.js';
|
||||
import { dir, docker, version } from '../util/product.js';
|
||||
import { paths } from '../util/storage.js';
|
||||
import { timeoutSignal } from '../util/misc.js';
|
||||
|
||||
@@ -12,6 +12,11 @@ const debug = createDebug('nxapi:update');
|
||||
const RELEASES_URL = 'https://api.github.com/repos/samuelthomas2774/nxapi/releases';
|
||||
|
||||
export async function checkUpdates() {
|
||||
if (docker) {
|
||||
debug('Running in Docker container, skipping update check');
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!process.versions.electron) {
|
||||
await fs.stat(path.join(dir, '.git'));
|
||||
|
||||
@@ -39,6 +39,15 @@ const match = pkg.version.match(/^(\d+\.\d+\.\d+)-next\b/i);
|
||||
export const version: string = match?.[1] ?? pkg.version;
|
||||
export const release: string | null = embedded_release ?? pkg.__nxapi_release ?? null;
|
||||
|
||||
export const docker: string | true | null = pkg.__nxapi_docker ?? await (async () => {
|
||||
try {
|
||||
await fs.stat('/.dockerenv');
|
||||
return true;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
export const git = typeof embedded_git !== 'undefined' ? embedded_git : pkg.__nxapi_git ?? await (async () => {
|
||||
try {
|
||||
await fs.stat(path.join(dir, '.git'));
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import * as process from 'node:process';
|
||||
import * as os from 'node:os';
|
||||
import { git, release, version } from '../util/product.js';
|
||||
import { docker, git, release, version } from '../util/product.js';
|
||||
|
||||
const default_useragent = 'nxapi/' + version + ' (' +
|
||||
(!release && git ? 'git ' + git.revision.substr(0, 7) + (git.branch ? ' ' + git.branch : '') + '; ' :
|
||||
!release ? 'no-git; ' : '') +
|
||||
(typeof docker === 'string' ? 'docker ' + docker + '; ' : docker ? 'docker; ' : '') +
|
||||
'node ' + process.versions.node + '; ' +
|
||||
process.platform + ' ' + os.release() +
|
||||
')';
|
||||
|
||||
Reference in New Issue
Block a user