Class NpmExecutor
- All Implemented Interfaces:
Renamable, ResourceProvider
A provider for execution resultss from invoking npm.
The provider produces resources in response to requests for
ExecResult's where the request's ResourceRequest.name() matches
this provider's name.
-
The provider first checks if a file
package.jsonexists, else it fails. If no directorynode_modulesexists orpackage.jsonis newer thannode_modules/.package-lock.jsonit invokesnpm init. -
Then, the provider retrieves all resources added by
required(Stream). While the provider itself does not process these resources, it is assumed that they are processed by the npm command and therefore need to be available. -
The provider invokes the function set with
provided(Function)and collects all resources. If the provided resources exist and no resource fromrequiredis newer then the provided resources found, the provider returns a result that indicates successful invocation. The date of the result is set to the newest date from the provided resources and the (existing) resources are attached. -
Else, the provider invokes npm, calls the function set with
providedagain and adds the result to theExecResultthat it returns.
The provider also uses the function set with provided(Function) to determine
the resources to be removed when it is invoked with a request for
Cleanliness.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the given arguments.doProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Name.Sets the function used to determine the resources provided by this provider.Convenience method to add aFileResourceto the required resources.Convenience method to add aFileTreeto the required resources.Add the givenStreamof resources to the required resources.Methods inherited from class AbstractProvider
context, name, newResource, of, rename, toString, vavrStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
of, resources
-
Constructor Details
-
NpmExecutor
Initializes a new NPM executor.- Parameters:
project- the project
-
-
Method Details
-
name
Name. -
args
Add the given arguments.- Parameters:
args- the arguments- Returns:
- the npm executor
-
required
Add the givenStreamof resources to the required resources.- Parameters:
resources- the resources- Returns:
- the npm executor
-
required
Convenience method to add aFileTreeto the required resources. Ifrootis a relative path, it is resolved against the project's directory.- Parameters:
root- the rootpattern- the pattern- Returns:
- the npm executor
-
required
Convenience method to add aFileResourceto the required resources. Ifpathis relative, it is resolved against the project's directory.- Parameters:
root- the root- Returns:
- the npm executor
-
provided
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the request for resources- Returns:
- the stream
-