Whether module is a TypeScript project.
DataFile instance of package.json
.
Package manager of the module.
Absolute path of the module's root directory, where package.json
is located.
Name of the module as defined in package.json
.
Name of the module without user name. For example: typescript
for @microsoft/typescript
.
Creates a new Module instance from current instance, which shares Data File Manager with current Module. Multiple instance work over same files efficiently and without collision.
Module instance.
Executes given command using execa.command
with given options. Applies sensible default options.
module.command("ls"); // Run `ls`.
module.command("ls -al", { stdio: "inherit" }); // Run `ls -al`.
is command to execute.
are passed to Execa.
[[ExecaReturnValue]] instance.
Ensures that the directory exists. If the directory structure does not exist, it is created similar to mkdir -p
.
is the path relative to module root or an absolute path.
Executes given command using execa
with given arguments and options. Applies sensible default options.
module.execute("ls"); // Run `ls`.
module.execute("ls", ["-al"], { stdio: "inherit" }); // Run `ls -al`.
is binary file to execute.
are arguments to pass to executable.
are passed to Execa.
[[ExecaReturnValue]] instance.
Executes given command using execa
with given arguments and options. Applies sensible default options.
module.execute("ls"); // Run `ls`.
module.execute("ls", { stdio: "inherit" }); // Run `ls`.
is binary file to execute.
are passed to Execa.
[[ExecaReturnValue]] instance.
Checks whether given path exists.
is the path relative to module root or an absolute path.
whether given path exists.
Fetches a dependent module's version from given dependency types.
is the name of the module to get version of.
are array of dependency types to search module in.
version of the moduleName
|| undefined.
Checks whether given module or any of the modules exist in given dependency types.
are the name of the module to search for.
are array of dependency types to search module in.
whether moduleName
exists in one of the dependency types.
Checks single or multiple module's existence in any of the package.json
dependencies.
are Module or modules to check whether this module has any dependency.
trueValue
if module depends on any of the moduleNames
. Otherwise returns falseValue
.
Checks single or multiple module's existence in any of the package.json
dependencies.
trueValue
if module depends on any of the moduleNames
. Otherwise returns falseValue
.
Checks single or multiple module's existence in any of the package.json
dependencies.
trueValue
if module depends on any of the moduleNames
. Otherwise returns falseValue
.
Installs node modules using specified package manager.
are package name or array of package names.
is the dependency type of the package. dev
, peer
, optional
etc.
Returns whether given path is a directory.
is the path relative to module root or an absolute path.
whether given path is a directory.
Checks whether content of pathInModule
file is equal to data
by making string comparison (for strings)
or deep comparison (for objects).
const isConfigEqual = module.isEqual("config.json", { someData: 4 });
const textEqual = module.isEqual("some.txt", "content");
is the path relative to module root or an absolute path.
is string or JavaScript object to compare to file's content.
whether the file is equal to given content
.
Returns absolute path for given relative path to module root. If given path is an absolute path, returns it directly.
module.pathOf("images", "photo.jpg"); // -> /path/to/root/images/photo.jpg
module.pathOf("/usr", "bin"); // -> /usr/bin
are path or array of path parts.
absolute path to given destination.
Reads and if possible returns DataFile otherwise file content. If file does not exist returns undefined
.
If options.defaultData
is true, file will be created using options.defaultData
if it does not exist.
is the path relative to module root or an absolute path.
are options passed to Manager.load
of edit-config
. See here.
DataFile instance, file content or undefined
.
Asynchronously reads the entire contents of a file using utf8
encoding.
is the path relative to module root or an absolute path.
file contents.
Returns relative path to module root for given absolute path. If given path is a relative path, returns it directly.
module.relativePathOf("/path/to/module/src/my-file.js"); // -> src/my-file.js
module.relativePathOf("src/my-file.js"); // -> src/my-file.js
are path or array of path parts.
path relative to module's root.
Removes file or directory relative to module's root. Removes directory even it has files in it. If the path does not exist, silently does nothing.
is the path relative to module root or an absolute path.
file path relative to module root if file is removed, undefined
otherwise.
Removes empty directories recursively for given path relative to module root.
is the path relative to module root or an absolute path.
array of deleted directories.
Renames given path.
is the old path relative to module root or an absolute path.
is the new path relative to module root or an absolute path.
is whether to allow rename operation if target path already exists. Silently ignores operation if overwrite is not allowed and target path exists.
whether file is renamed.
Saves all read data files.
Uninstalls node modules using specified package manager.
are package name or array of package names.
Writes given content to file. If content is an object, it is serialized.
If prettier
configuration and module is available and content is formatted using prettier
.
is the path relative to module root or an absolute path.
is the content to write to file.
is the format to be used in serialization if file does not exist and content is object.
is whether to overwrite existing file.
written content or [[DataFile]] if file is written, undefined
otherwise.
Returns package manager type.
is the absolute path of directory where package.json
is located.
type of package manager.
Returns root directory of the module by searching package.json
from given cwd
or environment variables
(INIT_CWD
by npm install
or CWD
) up.
is the path to start search from.
path of module root.
Creates and returns a Module instance.
are options.
is the default stdio
option to be used with command
and execute
methods.
is starting directory to start search for module root from.
is Winston compatible Logger to be used when logging.
is whether to overwrite files by default.
is package manager used by module.
Module instance.
Generated using TypeDoc
Class which provides information and modification methods for a module.