New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

build-dir

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-dir - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

test.js

61

index.js

@@ -6,15 +6,53 @@ 'use strict';

readPkgUp = require('read-pkg-up'),
path = require('path');
path = require('path'),
fs = require('fs'),
buildRoot = 'build';
function getBuildDir() {
function getBuildData(known) {
known = known || Object.create(null);
return Promise.all([
readPkgUp(),
branchName.assumeMaster()
]).then(function (data) {
known.branch || branchName.assumeMaster(),
known.version || readPkgUp().then((data) => {
return data.pkg.version;
})
]).then(function (data) {
return {
branch : data[0],
version : data[1]
};
});
}
function get(known) {
return getBuildData(known).then((data) => {
const
branch = data.branch,
version = data.version;
return path.join(buildRoot, branch, version);
});
}
function link() {
return getBuildData().then((data) => {
const
pkgData = data[0],
currBranch = data[1],
projectVersion = pkgData.pkg.version;
branch = data.branch,
version = data.version,
branchLatestPath = path.join(buildRoot, branch, 'latest');
return path.join('build', currBranch, projectVersion);
return new Promise((resolve) => {
fs.symlink(version, branchLatestPath, (err) => {
if (err) {
throw err;
}
fs.symlink(branchLatestPath, 'latest-build', (err) => {
if (err) {
throw err;
}
resolve();
});
});
});
});

@@ -24,3 +62,6 @@ }

module.exports = {
get : getBuildDir
// TODO: Use the shorthand syntax here when Node.js upgrades V8
// to a version that does not throw a SyntaxError.
get : get,
link
};

2

package.json
{
"name": "build-dir",
"version": "0.0.2",
"version": "0.1.0",
"description": "Get a place to put your build",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/solladay/build-dir",

@@ -28,3 +28,3 @@ # build-dir

````javascript
buildDir.get().then(function (dirPath) {
buildDir.get().then((dirPath) => {
console.log(dirPath);

@@ -34,2 +34,10 @@ });

Set up convenient `latest-build` and branch-specific `latest` links.
````javascript
buildDir.link().then(() => {
// latest-build now points to build/<branch>/latest,
// which in turn points to build/<branch>/<version>
});
````
## Contributing

@@ -36,0 +44,0 @@ See our [contributing guidelines](https://github.com/sholladay/build-dir/blob/master/CONTRIBUTING.md "The guidelines for being involved in this project.") for more details.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc