mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-21 05:24:45 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
80
node_modules/resolve/test/mock_sync.js
generated
vendored
Normal file
80
node_modules/resolve/test/mock_sync.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
var path = require('path');
|
||||
var test = require('tape');
|
||||
var resolve = require('../');
|
||||
|
||||
test('mock', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var files = {};
|
||||
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
||||
|
||||
var dirs = {};
|
||||
dirs[path.resolve('/foo/bar')] = true;
|
||||
|
||||
function opts(basedir) {
|
||||
return {
|
||||
basedir: path.resolve(basedir),
|
||||
isFile: function (file) {
|
||||
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
||||
},
|
||||
isDirectory: function (dir) {
|
||||
return !!dirs[path.resolve(dir)];
|
||||
},
|
||||
readFileSync: function (file) {
|
||||
return files[path.resolve(file)];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./baz', opts('/foo/bar')),
|
||||
path.resolve('/foo/bar/baz.js')
|
||||
);
|
||||
|
||||
t.equal(
|
||||
resolve.sync('./baz.js', opts('/foo/bar')),
|
||||
path.resolve('/foo/bar/baz.js')
|
||||
);
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('baz', opts('/foo/bar'));
|
||||
});
|
||||
|
||||
t.throws(function () {
|
||||
resolve.sync('../baz', opts('/foo/bar'));
|
||||
});
|
||||
});
|
||||
|
||||
test('mock package', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var files = {};
|
||||
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
||||
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
||||
main: './baz.js'
|
||||
});
|
||||
|
||||
var dirs = {};
|
||||
dirs[path.resolve('/foo')] = true;
|
||||
dirs[path.resolve('/foo/node_modules')] = true;
|
||||
|
||||
function opts(basedir) {
|
||||
return {
|
||||
basedir: path.resolve(basedir),
|
||||
isFile: function (file) {
|
||||
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
||||
},
|
||||
isDirectory: function (dir) {
|
||||
return !!dirs[path.resolve(dir)];
|
||||
},
|
||||
readFileSync: function (file) {
|
||||
return files[path.resolve(file)];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
t.equal(
|
||||
resolve.sync('bar', opts('/foo')),
|
||||
path.resolve('/foo/node_modules/bar/baz.js')
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue