mirror of
https://github.com/coder/code-server.git
synced 2024-12-25 18:52:34 +03:00
a328204d80
* Implements the fs module * Add stats object * Add not implemented to createWriteStream * Update mkdtemp to use tmp dir * Unexport Stats * Add client web socket for commands and restructure
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { exec } from "child_process";
|
|
import { existsSync, readdirSync } from "fs";
|
|
import { join, resolve } from "path";
|
|
import { logger, field } from "../packages/logger";
|
|
|
|
/**
|
|
* Install dependencies for a single package.
|
|
*/
|
|
const doInstall = (pkg: string, path: string): void => {
|
|
logger.info(`Installing "${pkg}" dependencies...`);
|
|
exec("yarn", {
|
|
cwd: path,
|
|
maxBuffer: 1024 * 1024 * 10,
|
|
}, (error, stdout, stderr) => {
|
|
if (error) {
|
|
logger.error(
|
|
`Failed to install "${pkg}" dependencies`,
|
|
field("error", error),
|
|
field("stdout", stdout),
|
|
field("stderr", stderr),
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
logger.info(`Successfully grabbed \"${pkg}\" dependencies!`);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Install dependencies for all packages.
|
|
*/
|
|
const handlePackages = (dir: string): void => {
|
|
readdirSync(dir).forEach((pkg) => {
|
|
const pkgDir = join(dir, pkg);
|
|
const pkgJsonPath = join(pkgDir, "package.json");
|
|
if (existsSync(pkgJsonPath)) {
|
|
doInstall(pkg, pkgDir);
|
|
}
|
|
});
|
|
};
|
|
|
|
handlePackages(resolve(__dirname, "..", "packages"));
|