modify the example node.js package to use chalk

because left-pad is deprecated
This commit is contained in:
Rui Lopes 2025-09-05 07:23:12 +00:00
parent 32b3b58a6b
commit 92ab9966d5
2 changed files with 9 additions and 7 deletions

View File

@ -45,10 +45,11 @@ cat >package.json <<'EOF'
} }
EOF EOF
cat >hello-world.js <<'EOF' cat >hello-world.js <<'EOF'
const leftPad = require('left-pad') import chalk from 'chalk';
console.log(leftPad('hello world', 40))
console.log(chalk.green('Hello, World!'));
EOF EOF
npm install --save left-pad npm install --save chalk
node hello-world.js node hello-world.js
# #

View File

@ -70,10 +70,11 @@ Set-Content `
-Encoding Ascii ` -Encoding Ascii `
hello-world-win.js ` hello-world-win.js `
@' @'
const leftPad = require('left-pad') import chalk from 'chalk';
console.log(leftPad('hello world', 40))
console.log(chalk.green('Hello, World!'));
'@ '@
npm install --save left-pad npm install --save chalk
node hello-world-win.js node hello-world-win.js
# #
@ -101,7 +102,7 @@ mkdir use-hello-world-win-npm | Out-Null
Push-Location use-hello-world-win-npm Push-Location use-hello-world-win-npm
Set-Content ` Set-Content `
-Encoding Ascii ` -Encoding Ascii `
hello-world-win.js ` package.json `
@' @'
{ {
"name": "use-hello-world-win", "name": "use-hello-world-win",