Skip to content

Commit

Permalink
add fnm test for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
flipatlas committed Feb 3, 2025
1 parent f94bf57 commit 4cb19bb
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.15.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Set the HOME directory to the directory of the script
$HOME = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Set the FNM_DIR variable
$FNM_DIR = Join-Path -Path $HOME -ChildPath ".fnm"

# Create the directory if it does not exist
if (-Not (Test-Path -Path $FNM_DIR)) {
New-Item -ItemType Directory -Path $FNM_DIR | Out-Null
}

# Download and execute the FNM install script
$zipUrl = "https://github.com/Schniz/fnm/releases/download/v1.38.1/fnm-windows.zip"
$zipFilePath = "$FNM_DIR\installer"
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFilePath

$destinationPath = $FNM_DIR
Expand-Archive -Path $zipFilePath -DestinationPath $destinationPath -Force

# Load the FNM environment and install Node.js version 20.15.1
"$FNM_DIR\fnm.exe" env --use-on-cd --shell powershell | Out-String | Invoke-Expression
"$FNM_DIR\fnm.exe" install 20.15.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.environmentVariables.HOME=${basedir}/target/it/node-version-manager/fnm/with-npm
invoker.environmentVariables.FNM_DIR=${basedir}/target/it/node-version-manager/fnm/with-npm/.fnm
invoker.environmentVariables.XDG_DATA_HOME=${basedir}/target/it/node-version-manager/fnm/with-npm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "example",
"version": "0.0.1",
"dependencies": {
"classnames": "^2.3.2"
},
"scripts": {
"prebuild": "npm install"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.eirslett</groupId>
<artifactId>fnm-with-npm</artifactId>
<version>0</version>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>@project.version@</version>

<configuration>
<workingDirectory>${basedir}</workingDirectory>
</configuration>

<executions>
<execution>
<id>install node</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm ci</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>ci</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def p = "powershell $basedir/install-fnm.ps1".execute()
p.waitForProcessOutput(System.out, System.err)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import org.codehaus.plexus.util.FileUtils

String buildLog = FileUtils.fileRead(new File(basedir, 'build.log'))
assert buildLog.contains('Using FNM version manager') : 'Node has been installed with a different version manager'

assert !new File(basedir, 'node/node').exists() : "Node was installed bypassing version manager"
assert new File(basedir, 'node_modules').exists() : "Node modules were not installed in the base directory"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignoring windows for now
invoker.os.family=windows

0 comments on commit 4cb19bb

Please sign in to comment.