UNPKG

538 BJavaScriptView Raw
1'use strict';
2var crypto = require('crypto');
3
4/*
5 * Create a cache key for the given name and dir. This is used for all the
6 * keys in the various caches within hash-for-dep.
7 *
8 * @param name is the 'require'-style name (i.e., could include a full path,
9 * or be relative to dir)
10 * @param dir optional directory to start resolution from when running
11 * the node-resolution algorithm as 'require' does.
12 */
13module.exports = function cacheKey(name, dir) {
14 return crypto.createHash('sha1').update(name + '\x00' + dir).digest('hex');
15};