JSON-only directives
If you want to use a JSON file, such as package.json
, jko
provides JSON-only directives—$extends
and $installs
—in addition to the script directives. Essentially, these directives ensure compatibility by allowing definitions from alternative sources to be used.
JSON-only Configuration:
$extends
– Enables extending scripts from external sources.$installs
– Defines dependencies that should be installed automatically.
"$directiveName": "value"
They are exclusively available when using .json
file.
While these are provided for compatibility purposes, it is recommended to use jko.js
instead.
$extends
To extend scripts in JSON, use the $extends
directive, which allows you to inherit scripts from an external source.
{
"scripts": {
"$extends": "./path/to/script.js"
}
}
- The external file contains predefined scripts that will be incorporated into the current configuration.
- This ensures reusability and modular script management across multiple configurations.
File can be any .js, .mjs, .cjs or .json file.
The file path must start with /
, ./
, or ../
.
To extend from a package:
{
"scripts": {
"$extends": "somePackageName"
}
}
The package must be available, i.e. it must be installed first.
When jko
is installed globally, only global packages will be available.
Solutions:
- Use a locally installed version of
jko
. - Use
jko.js
, a custom JavaScript configuration file, or a combination of.js
and.json
configuration files.
$installs
To set dependencies from an external source, use the $installs
directive within the scripts
object. This directive allows you to specify the file or package that contains the dependency definitions.
{
"scripts": {
"$installs" : "./some/path/dependencies.js",
}
}
File can be any .js, .mjs, .cjs or .json file.
The file path must start with /
, ./
, or ../
.
To use a package:
{
"scripts": {
"$installs" : "somePackageName",
}
}
The package must be available, i.e. it must be installed first.
For the specified $installs
, only dependencies
and devDependencies
are parsed for installation; the packageManager
setting is ignored. If you require a package manager other than the default, please use alternative configuration methods.