33 lines
951 B
PowerShell
33 lines
951 B
PowerShell
#!/usr/bin/env powershell
|
|
# https://docs.sheetjs.com/docs/demos/math/tensorflow#nodejs-demo
|
|
|
|
$oldDir = Get-Location
|
|
$tempDir = Join-Path -Path $env:TEMP -ChildPath "sheetjs-tfjs-csv"
|
|
if (Test-Path -Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force }
|
|
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
|
Set-Location -Path $tempDir
|
|
|
|
npm init -y
|
|
|
|
npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz @tensorflow/tfjs @tensorflow/tfjs-node
|
|
|
|
Invoke-WebRequest -Uri "https://docs.sheetjs.com/tfjs/SheetJSTF.js" -OutFile "SheetJSTF.js"
|
|
|
|
# this version uses `nvm` to cycle through node versions
|
|
$nvmCommandAvailable = Get-Command "nvm" -ErrorAction SilentlyContinue
|
|
if(! ($nvmCommandAvailable)) {
|
|
node --version
|
|
node SheetJSTF.js
|
|
} else {
|
|
|
|
$versions = @(20, 22, 24)
|
|
foreach ($n in $versions) {
|
|
nvm install $n
|
|
nvm use $n
|
|
node --version
|
|
node SheetJSTF.js
|
|
}
|
|
}
|
|
|
|
Set-Location $oldDir
|
|
Remove-Item -Path $tempDir -Recurse -Force |