Skip to content

Commit

Permalink
feat(cli): run script in space command
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Aug 12, 2023
1 parent ca84ce3 commit 14e7e1d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/cli/src/system/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { execSync } from 'node:child_process';

import openEditor from 'open-editor';
import { type Breadc, breadc } from 'breadc';
import { AnimeSystem, onDeath } from '@animespace/core';
Expand All @@ -24,7 +26,14 @@ function registerApp(system: AnimeSystem, app: Breadc<{}>) {
.option('--open', 'Open space in your editor')
.action(async options => {
const root = options.storage ? system.space.storage : system.space.root;
if (options.open) {
const cmds = options['--'];
if (cmds.length > 0) {
const isTTY = !!process?.stdout?.isTTY;
if (isTTY) {
system.printSpace();
}
execSync(cmds.join(' '), { cwd: root, stdio: 'inherit' });
} else if (options.open) {
try {
openEditor([root]);
} catch (error) {
Expand Down

0 comments on commit 14e7e1d

Please sign in to comment.