Get a place to put your build
- Fast and convenient, easy to set up.
- Namespaces builds in a human-friendly manner.
- Encourages cache-safe URLs.
- Uses a solid convention,
build/<branch>/<version>
. - Gracefully handles edge cases for git branches.
npm install build-dir --save
Get it into your program.
const buildDir = require('build-dir');
Get a path to use when writing the build.
buildDir().then((dirPath) => {
console.log('Build directory:', dirPath);
// 'build/master/1.0.0'
});
Get the path that was used for the most recent build.
buildDir.latest().then((dirPath) => {
console.log('Build directory:', dirPath);
// 'build/master/0.1.0'
});
Set up convenient latest-build
and branch-specific latest
links.
buildDir.link({ branch : 'dev', version : '1.1.1' }).then(() => {
console.log('Linking complete.')
// latest-build -> build/dev/latest -> build/dev/1.1.1
});
Let us manage the lifecycle steps for you.
buildDir.prepare().then((dir) => {
// Put stuff in here:
console.log('Temp dir:', dir.path);
// ... some time later ...
// Move the temp dir to its permanent home and set up
// latest links.
return dir.finalize();
});
Returns a Promise
for a path to use for your build. Does not create the path on disk (use prepare()
and/or link()
for that). Defaults to the current branch of the cwd
and a newly generated version.
Same as buildDir()
, except the branch
defaults to the most recently built branch and version
defaults to the most recently built version of the branch
.
Returns a Promise
. Within the cwd
, writes a symlink at latest-build
pointing to build/<branch>/latest
and from there to <version>
. No default branch
or version
is used, you must provide them, since linking requires an existing build path on disk and relevant build data.
Returns a Promise
for an object with these fields:
path
is a newly created temporary directory for you to write the build to.finalize()
movespath
to its final location and runsbuildDir.link()
to point to it.
Type: object
Type: string
Default: process.cwd()
Parent directory of the build root. Used to determine branch
and version
information when they are not provided.
Type: string
A git branch name. Unless otherwise specified, defaults to the HEAD branch of the cwd
.
Type: string
A build version. Where necessary, one will be constructed for you based on package.json and git repository data.
- delivr - Build your code and ship it to S3
- build-files - Read the files from your build
- build-keys - Get the paths of files from your build
- build-data - Get metadata for your build
- build-path - Get a path for the given build
- build-version - Get a version for your build
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
Go make something, dang it.