mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-08-17 02:10:31 +03:00
add filesystem test
This commit is contained in:
parent
df26fb319f
commit
bf07b8fb37
@ -98,9 +98,9 @@
|
||||
|
||||
```nix
|
||||
{
|
||||
"node_modules/tap-dot" = {
|
||||
"node_modules/tap-dot" = {
|
||||
bins = {
|
||||
"node_modules/.bin/tap-dot" = "node_modules/tap-dot/bin/dot";
|
||||
"node_modules/.bin/tap-dot" = "node_modules/tap-dot/bin/dot";
|
||||
};
|
||||
source = «derivation tap-dot.drv»;
|
||||
};
|
||||
|
@ -20,54 +20,55 @@
|
||||
else "dist";
|
||||
};
|
||||
|
||||
/**
|
||||
A Convinient wrapper around sanitizeGraph
|
||||
which allows to pass options such as { dev=false; }
|
||||
/*
|
||||
*
|
||||
A Convinient wrapper around sanitizeGraph
|
||||
which allows to pass options such as { dev=false; }
|
||||
|
||||
*/
|
||||
getSanitizedGraph = {
|
||||
# The lockfile entry; One depdency used as a root.
|
||||
plent,
|
||||
# The dependency 'graph'. See: sanitizeGraph
|
||||
pdefs,
|
||||
/**
|
||||
Drops dependencies including their subtree connection by filter attribute.
|
||||
|
||||
for example:
|
||||
# The lockfile entry; One depdency used as a root.
|
||||
plent,
|
||||
# The dependency 'graph'. See: sanitizeGraph
|
||||
pdefs,
|
||||
/*
|
||||
*
|
||||
Drops dependencies including their subtree connection by filter attribute.
|
||||
|
||||
```
|
||||
filterTree = {
|
||||
dev = false;
|
||||
};
|
||||
```
|
||||
for example:
|
||||
|
||||
Will filter out all dev dependencies including all children below dev-dependencies.
|
||||
```
|
||||
filterTree = {
|
||||
dev = false;
|
||||
};
|
||||
```
|
||||
|
||||
Which will result in a prod only tree.
|
||||
*/
|
||||
filterTree ? {},
|
||||
}:
|
||||
let
|
||||
Will filter out all dev dependencies including all children below dev-dependencies.
|
||||
|
||||
Which will result in a prod only tree.
|
||||
*/
|
||||
filterTree ? {},
|
||||
}: let
|
||||
root = {
|
||||
name = plent.name;
|
||||
version = plent.version;
|
||||
name = plent.name;
|
||||
version = plent.version;
|
||||
};
|
||||
graph = pdefs;
|
||||
in
|
||||
graphUtils.sanitizeGraph {
|
||||
inherit root graph;
|
||||
pred = (
|
||||
e:
|
||||
l.foldlAttrs (
|
||||
res: name: value:
|
||||
if res == false
|
||||
then false
|
||||
else value == e.${name}
|
||||
)
|
||||
true
|
||||
filterTree
|
||||
);
|
||||
};
|
||||
in
|
||||
graphUtils.sanitizeGraph {
|
||||
inherit root graph;
|
||||
pred = (
|
||||
e:
|
||||
l.foldlAttrs (
|
||||
res: name: value:
|
||||
if res == false
|
||||
then false
|
||||
else value == e.${name}
|
||||
)
|
||||
true
|
||||
filterTree
|
||||
);
|
||||
};
|
||||
in {
|
||||
inherit getInfo getSanitizedGraph;
|
||||
}
|
||||
|
@ -35,6 +35,58 @@ in {
|
||||
};
|
||||
};
|
||||
};
|
||||
# Currently only "dist" packages
|
||||
# can be used to populate node_modules
|
||||
test_only_dist = let
|
||||
graph = {
|
||||
"a"."1" = {
|
||||
dist = "<Source A Derivation>";
|
||||
dependencies = {
|
||||
b.version = "1";
|
||||
};
|
||||
dev = false;
|
||||
bins = {
|
||||
};
|
||||
info = {
|
||||
initialState = "source";
|
||||
allPaths = {
|
||||
"" = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
"b"."1" = {
|
||||
dist = "<B Derivation>";
|
||||
dependencies = {};
|
||||
dev = false;
|
||||
bins = {
|
||||
};
|
||||
info = {
|
||||
initialState = "dist";
|
||||
allPaths = {
|
||||
"node_modules/b" = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sanitizedGraph = utils.sanitizeGraph {
|
||||
inherit graph;
|
||||
root = {
|
||||
name = "a";
|
||||
version = "1";
|
||||
};
|
||||
};
|
||||
|
||||
fileSystem = utils.getFileSystem graph sanitizedGraph;
|
||||
in {
|
||||
expr = fileSystem;
|
||||
expected = {
|
||||
"node_modules/b" = {
|
||||
bins = {};
|
||||
source = "<B Derivation>";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test_cyclic_dependency = let
|
||||
graph = {
|
||||
|
Loading…
Reference in New Issue
Block a user