1.0.4 • Published 1 year ago
pakaje v1.0.4
Create a default config object
The Pakaje
static class is the entry point of every instruction.
import {Pakaje} from "pakaje";
const config = Pakaje.new("my-app");
This will generate a default PackageJson
object.
Update properties
You can find every property of a package.json file in a PackageJson
object.
config.version = "1.0.1";
config.dependencies = {
"some-dependency":"^2.3.4"
}
And so on...
Save configuration
save
and saveSync
will save the configuration in the package.json
in the current directory.
// sync
Pakaje.saveSync(config);
//async
await Pakaje.save(config);
// or...
Pakaje.save(config)
.then(()=>/**...*/)
.catch(err=>/**...*/)
Adding a path as second parameter will save the configuration in the given file name and path.
// sync
Pakaje.saveSync(config,"./new-path/package.json");
//async
await Pakaje.save(config,"./new-path/package.json");
// or...
Pakaje.save(config,"./new-path/package.json")
.then(()=>/**...*/)
.catch(err=>/**...*/)
Load configuration
load
and loadSync
will load the configuration from the package.json
in the current directory.
//sync
Pakaje.loadSync();
// async
const loaded = await Pakaje.load();
// or...
Pakaje.load()
.then(data=>/**...*/)
.catch(err=>/**...*/)
Adding a path as second parameter will load the configuration from another location.
//sync
Pakaje.loadSync("./custom-path/package.json");
// async
const loaded = await Pakaje.load("./custom-path/package.json");
// or...
Pakaje.load("./custom-path/package.json")
.then(data=>/**...*/)
.catch(err=>/**...*/)