Skip to content

Commit 28e7d02

Browse files
committed
Add cssd upgrade
1 parent fb61e52 commit 28e7d02

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

bin/handler.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'node:fs';
22
import path from 'node:path';
33
import os from 'node:os';
44
import { stdin } from 'node:process';
5+
import { execSync } from 'node:child_process';
56

67
import { pkg, config, configPath, configDownloadPath } from '../src/static.js'
78
import { parse } from '../src/parse.js';
@@ -128,6 +129,11 @@ export function getProgramName() {
128129
return pkg.bin[name] ? name : 'cssd';
129130
}
130131

132+
export function handleUpgrade() {
133+
console.log('Upgrading CLI...');
134+
execSync('npm update -g @css-doodle/cli', { stdio: 'inherit' });
135+
}
136+
131137
async function read(path) {
132138
let content = '';
133139
let error = null;

bin/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
handleDisplayConfig,
1414
handleDisplayConfigList,
1515
handleUseAction,
16+
handleUpgrade,
1617
getProgramName
1718
} from './handler.js';
1819

@@ -100,6 +101,11 @@ program
100101
.argument('[source]', 'css-doodle source file to parse')
101102
.action(handleParse);
102103

104+
program
105+
.command('upgrade')
106+
.description('Upgrade CLI to the latest version')
107+
.action(handleUpgrade);
108+
103109
if (process.argv.length <= 2) {
104110
program.help();
105111
} else {

0 commit comments

Comments
 (0)