Skip to content

Commit

Permalink
cli: add support for version launch hint
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Aug 28, 2024
1 parent d238d8d commit 3b6454f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/cli/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
],
"preLaunchTask": "npm: build",
"args": [
"rtsp",
"/Volumes/Seagate/video/scrypted-1370/1720470474217/1720470474217/1720470474217.rtsp",
"serve",
],
"sourceMaps": true,
"resolveSourceMapLocations": [
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrypted",
"version": "1.3.19",
"version": "1.3.20",
"description": "",
"main": "./dist/packages/cli/src/main.js",
"bin": {
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function sleep(ms: number) {

const EXIT_FILE = '.exit';
const UPDATE_FILE = '.update';
const VERSION_FILE = '.version';

async function runCommand(command: string, ...args: string[]) {
if (os.platform() === 'win32') {
Expand Down Expand Up @@ -117,6 +118,15 @@ export async function installServe(installVersion: string, ignoreError?: boolean
}

export async function serveMain(installVersion?: string) {
const { installDir, volume } = cwdInstallDir();
if (!installVersion) {
try {
installVersion = fs.readFileSync(path.join(volume, VERSION_FILE)).toString().trim();
}
catch (e) {
}
}

const options = ((): { install: true; version: string } | { install: false } => {
if (installVersion) {
console.log(`Installing @scrypted/server@${installVersion}`);
Expand All @@ -139,7 +149,6 @@ export async function serveMain(installVersion?: string) {
}
})();

const { installDir, volume } = cwdInstallDir();

if (options.install) {
await installServe(options.version, true);
Expand Down

0 comments on commit 3b6454f

Please sign in to comment.