Skip to content

Commit

Permalink
ensure prettier is installed (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll authored Sep 5, 2024
1 parent f11ff7b commit 4d0c83c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
id: commit-message
run: |
echo "message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
- name: npm ci --ignore-scripts
run: |
npm ci --ignore-scripts
- name: 🔨 Use .NET Core 8.0 SDK
uses: actions/setup-dotnet@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions src/Nuke/GithubActions/GitHubActionsLintAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public override ConfigurationEntity GetConfiguration(IReadOnlyCollection<Executa
step.Ref = "${{ github.event.pull_request.head.ref }}";
}
)
.InsertAfterCheckOut(
new RunStep("npm ci --ignore-scripts") { Run = "npm ci --ignore-scripts", }
)
.InsertAfterCheckOut(
new RunStep("Get Head Commit Message") { Id = "commit-message", Run = "echo \"message=$(git show -s --format=%s)\" >> \"$GITHUB_OUTPUT\"", }
)
Expand Down
12 changes: 12 additions & 0 deletions src/Nuke/ICanPrettier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public interface ICanPrettier : ICanLint
? makeArgsForStagedFiles(LintPaths.Glob(PrettierMatcher))
: new Arguments().Concatenate(_prettierBaseArgs).Add(".").Add("--write");

if (( NukeBuild.RootDirectory / "package.json" ).FileExists() && !NukeBuild.RootDirectory.ContainsDirectory("node_modules"))
{
ProcessTasks
.StartProcess(
ToolPathResolver.GetPathExecutable("npm"),
NukeBuild.IsLocalBuild ? "install" : "ci --ignore-scripts",
NukeBuild.RootDirectory
)
.AssertWaitForExit()
.AssertZeroExitCode();
}

return ProcessTasks
.StartProcess(
ToolPathResolver.GetPathExecutable("npm"),
Expand Down

0 comments on commit 4d0c83c

Please sign in to comment.