Comments (1)
it might just be easiest to call the hasura pro cli directly from ts using shelljs?
//#region Global Imports
import * as shell from 'shelljs';
//#endregion Global Imports
//#region Local Imports
import {
ShellExecResponse,
ShellExecSuccess,
ShellExecError,
ShellExecTimeoutError,
ShellExecNotFoundError,
} from './Responses';
import { ShellExecOptions } from '@Modules/shell-utils/Interfaces';
//#endregion Local Imports
export const SHELL_DEFAULT_SETTINGS: ShellExecOptions = {
silent: true,
simple: true,
};
/*eslint complexity: ["error", 9]*/
export const handleShellResponse = (
code: number | null,
stdout: string | null,
stderr: string | null,
command: string,
settings: ShellExecOptions,
resolve: (value?: ShellExecSuccess) => void,
reject: (value?: ShellExecError) => void,
): void => {
switch (code) {
case 0: // success
return resolve(
new ShellExecSuccess(code, stdout, stderr, command, settings),
);
// If there is an error then reject
case null: // timeout
return reject(
new ShellExecTimeoutError(code, stdout, stderr, command, settings),
);
case 127: // not-found
return reject(
new ShellExecNotFoundError(code, stdout, stderr, command, settings),
);
case 1: // Catch-all
case 2: // Misuse of shell builtins (according to Bash documentation)
case 126: // Command invoked cannot execute
case 128: // Invalid argument to exit
case 130: // Script terminated by Control-C
default:
return reject(
new ShellExecError(code, stdout, stderr, command, settings),
);
}
};
export const shellExec = async (
command: string,
settings: ShellExecOptions = SHELL_DEFAULT_SETTINGS,
): Promise<ShellExecResponse> => {
return new Promise((resolve, reject) => {
shell.exec(
command,
settings,
(code: number | null, stdout: string | null, stderr: string | null) => {
handleShellResponse(
code,
stdout,
stderr,
command,
settings,
resolve,
reject,
);
},
);
});
};
from create-full-stack.
Related Issues (20)
- Expo AuthSession expiration
- Setup demo-full-stack for production use
- Pulumi Fargate timeouts HOT 2
- Set "refreshToken" "rotationType" to "rotating" with Pulumi
- Suggestions for additional resource config settings HOT 9
- Upgrade Expo and React versions
- Pulumi plugins in setup.html
- Watchman crawl failed. Retrying once with node crawler
- Windows support
- Mobile/Expo web support
- Absolute import on each packages HOT 1
- Support npm v7
- Upgrade to CRA v4
- ESLint Error on create HOT 5
- Incorrect peer dependencies HOT 3
- Contribution guide HOT 2
- Pulumi Hasura Cloud Provider HOT 2
- Hasura TS Metadata SDK HOT 1
- react native setTimeout Android warning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-full-stack.