Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cache breaker to roadrunner cache #1965

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bin/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,27 @@ if (semver.satisfies(ver, '>=5.0.0')) {
process.exit(1);
}

// init roadrunner
// ensure cache directory exists
var mkdirp = require('mkdirp');
var constants = require('../lib-legacy/constants');
mkdirp.sync(constants.GLOBAL_INSTALL_DIRECTORY);
mkdirp.sync(constants.MODULE_CACHE_DIRECTORY);

// init roadrunner
var YARN_VERSION = require('../package.json').version;
var roadrunner = require('roadrunner');

// load cache
roadrunner.load(constants.CACHE_FILENAME);
var cacheVersion = roadrunner.get('CACHE_BREAKER').version;
if (!cacheVersion || cacheVersion !== YARN_VERSION) {
// reset cache if it's for an older yarn
roadrunner.reset(constants.CACHE_FILENAME);
}
// set this cache to the current yarn version
roadrunner.set('CACHE_BREAKER', {version: YARN_VERSION});

// save cache on SIGINT
roadrunner.setup(constants.CACHE_FILENAME);

var i = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* @flow */

const path = require('path');
let userHome = require('user-home');

if (process.platform === 'linux' && process.env.USER === 'root') {
userHome = path.resolve('/usr/local/share');
}
Expand Down