Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Webtools releases

## [Unreleased]
### Added
- Task like `npm run lint:fix` get turned into `npm_run_lint-fix` (so the colons don't screw up Gradle)

## [1.1.0] - 2024-08-04
### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ node {
inputs.dir('somedir').withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir('build/some-output')
}
// if an npm script contains `:` it willbe transformed into `-`
npm_run 'lint:fix', {} // becomes `npm_run_lint-fix`
}
```

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/diffplug/webtools/node/NodePlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 DiffPlug
* Copyright (C) 2024-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,8 +53,8 @@ public Extension(Project project) {
}

public TaskProvider<?> npm_run(String name, Action<NpmRunTask> taskConfig) {
return project.getTasks().register("npm_run_" + name, NpmRunTask.class, task -> {
task.taskName = name;
return project.getTasks().register("npm_run_" + name.replace(':', '-'), NpmRunTask.class, task -> {
task.npmTaskName = name;
try {
setup.nodeVersion = nvmRc(findNvmRc(project.getProjectDir()));
setup.npmVersion = "provided";
Expand All @@ -75,12 +75,12 @@ public TaskProvider<?> npm_run(String name, Action<NpmRunTask> taskConfig) {

@CacheableTask
public abstract static class NpmRunTask extends DefaultTask {
public String taskName;
public String npmTaskName;
private TreeMap<String, String> environment = new TreeMap<>();

@Input
public String getTaskName() {
return taskName;
public String getNpmTaskName() {
return npmTaskName;
}

@Input
Expand All @@ -101,7 +101,7 @@ public void npmCiRunTask() throws Exception {
setup.start(getProjectDir().get().getAsFile());
// run the gulp task
ProxyConfig proxyConfig = new ProxyConfig(Collections.emptyList());
setup.factory().getNpmRunner(proxyConfig, null).execute("run " + taskName, environment);
setup.factory().getNpmRunner(proxyConfig, null).execute("run " + npmTaskName, environment);
}
}

Expand Down
Loading