Skip to content

Commit

Permalink
fix(node): Print with stdio
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Dec 3, 2023
1 parent eb7c1f2 commit 81cb627
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmds/core/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.builder = async (yargs) => {

exports.handler = async (argv) => {
if (!UTIL.which('docker')) {
console.log("Docker is not installed (cannot find `docker' executable)");
console.warn("Docker is not installed (cannot find `docker' executable)");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion cmds/core/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports.builder = async (yargs) => {
yargs.help(false);
yargs.version(false);
yargs.getOptions().narg = [];
//console.log(yargs.getOptions());
//console.warn(yargs.getOptions());
};

exports.handler = async (argv) => {
Expand Down
3 changes: 1 addition & 2 deletions cmds/core/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports.handler = async (argv) => {
, argv.files);
break;
default:
console.log(`Invalid argument, from: ${argv.from}`);
console.warn(`Invalid argument, from: ${argv.from}`);
break;
}
} else {
Expand Down Expand Up @@ -180,7 +180,6 @@ function ask(question, callback) {
*/
function check_eask_filename(name) {
let base = path.basename(name);
console.log(base);
let prefix;
if (base.startsWith('Easkfile')) prefix = 'Easkfile';
else if (base.startsWith('Eask')) prefix = 'Eask';
Expand Down
14 changes: 7 additions & 7 deletions cmds/create/elpa.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ exports.handler = async (argv) => {

proc.on('close', function (code) {
if (code == 0) {
console.log('✓ Done cloning the ELPA template');
console.log('');
console.warn('✓ Done cloning the ELPA template');
console.warn('');
process.chdir(project_name);
_cloned(argv);
return;
}
// Help instruction here!
console.log('✗ Error while cloning template project');
console.log('');
console.log(' [1] Make sure you have git installed and has the right permission');
process.stdout.write(` [2] Failed because of the target directory isn't empty`);
console.warn('✗ Error while cloning template project');
console.warn('');
console.warn(' [1] Make sure you have git installed and has the right permission');
process.stderr.write(` [2] Failed because of the target directory isn't empty`);
});
}

/* Operations after _cloned */
async function _cloned(argv) {
console.log('Initialize the Eask-file for your project...');
console.warn('Initialize the Eask-file for your project...');
await init.create_eask_file();
UTIL.e_call(argv, 'create/elpa');
}
14 changes: 7 additions & 7 deletions cmds/create/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ exports.handler = async (argv) => {

proc.on('close', function (code) {
if (code == 0) {
console.log('✓ Done cloning the elisp package template');
console.log('');
console.warn('✓ Done cloning the elisp package template');
console.warn('');
process.chdir(project_name);
_cloned(argv);
return;
}
// Help instruction here!
console.log('✗ Error while cloning template project');
console.log('');
console.log(' [1] Make sure you have git installed and has the right permission');
process.stdout.write(` [2] Failed because of the target directory isn't empty`);
console.warn('✗ Error while cloning template project');
console.warn('');
console.warn(' [1] Make sure you have git installed and has the right permission');
process.stderr.write(` [2] Failed because of the target directory isn't empty`);
});
};

/* Operations after _cloned */
async function _cloned(argv) {
console.log('Initialize the Eask-file for your project...');
console.warn('Initialize the Eask-file for your project...');
await init.create_eask_file();
UTIL.e_call(argv, 'create/package');
}
2 changes: 1 addition & 1 deletion cmds/run/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function startCommand(commands, count) {

let command = commands[count];

console.log('[RUN]: ' + command);
console.warn('[RUN]: ' + command);

let proc = spawn(command, { stdio: 'inherit', shell: true });

Expand Down
6 changes: 3 additions & 3 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function _environment_name (argv) {
*/
async function e_call(argv, script, ...args) {
if (!which(EASK_EMACS)) {
console.log("Emacs is not installed (cannot find `" + EASK_EMACS + "' executable)");
console.warn("Emacs is not installed (cannot find `" + EASK_EMACS + "' executable)");
return;
}

Expand All @@ -230,8 +230,8 @@ async function e_call(argv, script, ...args) {
console.log('');
}
if (5 <= argv.verbose) { // `all` scope
console.log('[EXEC] ' + EASK_EMACS + ' ' + cmd.join(' '));
console.log('');
console.warn('[EXEC] ' + EASK_EMACS + ' ' + cmd.join(' '));
console.warn('');
}

setup_env();
Expand Down

0 comments on commit 81cb627

Please sign in to comment.