Winston compatible logger.
Module instance of node module which is used as source for modification operations such as copy, update.
Module instance of node module which is used as target for modification operations such as copy, update.
Returns whether given files from source module and target module are equal using method described below:
JSON
or YAML
, returns whether they are deeply equal. (Objects does not have to have same key order.).js
and .ts
files, files are transpiled and minified then copmpared. (To overcome comment and simple format changes.)intermodular("module-files/src/address.js", "src/address.js");
intermodular("module-files/config/.eslintrc", ".eslintrc");
intermodular("module-files/some.txt", "some.txt");
is the file path relative to source module root.
is the file path relative to target module root. If not provided uses same relative path as sourceModuleFilePath
.
whether given files are equivalent.
Executes given command using execa.command
with cwd as target module's root. Additionally adds source module's node_modules/.bin
to path.
intermodular.command("ls"); // Run `ls`.
intermodular.command("ls -al", { stdio: "inherit" }); // Run `ls -al`.
is command to execute.
are passed to Execa.
[[ExecaReturnValue]] instance.
Copies a file or directory from pathInSourceModule
relative to source module root to pathInTargetModule
relative to
target module root. The directory can have contents. Like cp -r.
IMPORTANT: Note that if source is a directory it will copy everything inside of this directory, not the entire directory itself.
// Copy everything in `/path/to/project/node_modules/module-a/src/config/` to `/path/to/project/`
const copiedPaths = copySync("src/config", ".");
const copiedFiles = copySync("src/config", ".", { excludeDirFromReturn: true });
is source to copy from.
is destination to copy to. Cannot be a directory.
copied files and directories. Directories can be optionally excluded.
Executes given command using execa
with given arguments and options with cwd as target module's root. Applies sensible default options.
Additionally adds source module's node_modules/.bin
to path.
intermodular.execute("ls"); // Run `ls`.
intermodular.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 with cwd as target module's root. Applies sensible default options.
Additionally adds source module's node_modules/.bin
to path.
intermodular.execute("ls"); // Run `ls`.
intermodular.execute("ls", { stdio: "inherit" }); // Run `ls`.
is binary file to execute.
are passed to Execa.
[[ExecaReturnValue]] instance.
Creates;
fs-extra
copy
filter function.is wether to return copied files only. If this is true, directories are excluded from return value.
intermodular
copy filter function.
is whether overwirte option is passed to fs-extra
copy
function.
fs-extra
copy
compatible filter function and log function and function to get copied paths.
Logs given message with required level using logger provided during object construction.
is the level to log message.
is the message to log.
Throws if source or target file are undefined.
Returns whether variable
is set in environment variables and not empty.
is name of the environment variable to check.
whether given environment variable is set and not empty.
Creates and returns Intermodular instance.
are options
is Winston compatible logger or console
.
is whether to overwrite files by default.
is the source module or a path in source module. By default immediate parent's root dir is used. Immediate parent is the file which calls this method.
is the target module or a path in target module. By default process.env.INIT_CWD
or process.env.CWD
is used whichever is first available.
Intermodular instance.
Parses and returns variable
environment variable. If value is JSON object, parses using JSON5 and returns it as a JavaScript object.
Otherwise returns defaultValue
.
is Name of the environment variable
is value to return if no environment variable is set or is empty.
environment variable (if possible as an object) or default value.
Generated using TypeDoc
Configuration for source module in target module as a DataFile instance.