@arshtiwari11111/sltrain 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/train.js +42 -0
- package/package.json +15 -0
package/bin/train.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const psScript = `
|
|
6
|
+
$train = @(
|
|
7
|
+
" ==== ___________ _________________ "
|
|
8
|
+
" _D _| L_Y_ [ ][ ]"
|
|
9
|
+
" [__|-______|- | || |"
|
|
10
|
+
" |/-O-O-O-O| |____________||_________________|"
|
|
11
|
+
" '========' '=oo====oo=' '=oo====oo====oo='"
|
|
12
|
+
)
|
|
13
|
+
Clear-Host
|
|
14
|
+
[Console]::CursorVisible = $false
|
|
15
|
+
$windowWidth = [Console]::WindowWidth
|
|
16
|
+
for ($x = $windowWidth; $x -ge -50; $x--) {
|
|
17
|
+
for ($y = 0; $y -lt $train.Count; $y++) {
|
|
18
|
+
[Console]::SetCursorPosition(0, $y + 5)
|
|
19
|
+
$printX = [Math]::Max(0, $x)
|
|
20
|
+
$spaces = New-Object String ' ', $printX
|
|
21
|
+
if ($x -lt 0) {
|
|
22
|
+
$sliceStart = [Math]::Abs($x)
|
|
23
|
+
if ($sliceStart -lt $train[$y].Length) {
|
|
24
|
+
Write-Host ($train[$y].Substring($sliceStart)) -NoNewline
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
Write-Host ($spaces + $train[$y]) -NoNewline
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
Start-Sleep -Milliseconds 25
|
|
31
|
+
}
|
|
32
|
+
[Console]::CursorVisible = $true
|
|
33
|
+
Clear-Host
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const child = spawn('powershell.exe', ['-NoProfile', '-Command', psScript], {
|
|
37
|
+
stdio: 'inherit'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
child.on('exit', () => {
|
|
41
|
+
process.exit();
|
|
42
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arshtiwari11111/sltrain",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A classic Steam Locomotive command line train animation for native Windows terminal windows.",
|
|
5
|
+
"main": "bin/train.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sltrain": "./bin/train.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": ["train", "sl", "windows", "ascii", "animation"],
|
|
10
|
+
"author": "Arsh",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
}
|
|
15
|
+
}
|