-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
export const run = ` | ||
#!/bin/bash | ||
set -e | ||
import { resolve } from 'path' | ||
|
||
for dir in packages/* distributions/* ; do | ||
# echo "$dir" | ||
pushd $dir > /dev/null | ||
$@ | ||
popd > /dev/null | ||
done | ||
` | ||
import consola from 'consola' | ||
import { bold, gray } from 'chalk' | ||
import { existsSync } from 'fs-extra' | ||
|
||
interface RunCommandOptions { | ||
file: string | ||
args: string[] | ||
} | ||
|
||
export async function run({ file, args }: RunCommandOptions) { | ||
const filepath = resolve(process.cwd(), file) | ||
if (!(file.endsWith('.js') || file.endsWith('.ts'))) { | ||
return consola.error(`${bold('siroc run')} should take a .js or .ts file.`) | ||
} | ||
if (!existsSync(filepath)) { | ||
return consola.error(`${bold(filepath)} could not be found.`) | ||
} | ||
process.argv = [filepath, ...args] | ||
try { | ||
// eslint-disable-next-line | ||
const jiti = require('jiti')(__filename) | ||
jiti(filepath) | ||
consola.success(`Ran ${bold(file)}\n`) | ||
} catch (e) { | ||
consola.error( | ||
`Error running ${bold(file)}\n`, | ||
gray(process.stderr.toString().trim()) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const run = ` | ||
#!/bin/bash | ||
set -e | ||
for dir in packages/* distributions/* ; do | ||
# echo "$dir" | ||
pushd $dir > /dev/null | ||
$@ | ||
popd > /dev/null | ||
done | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters