Skip to content

Commit

Permalink
test: cleanup tree outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Jan 13, 2021
1 parent c644a81 commit 11ee91f
Show file tree
Hide file tree
Showing 13 changed files with 1,099 additions and 1,186 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"alphanum-sort": "^1.0.2",
"apr-for-each": "^3.0.3",
"apr-intercept": "^3.0.4",
"apr-main": "^4.0.3",
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/js-nm-individually/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8342,7 +8335,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/js-nm-single/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8342,7 +8335,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/js-pnp-individually/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8342,7 +8335,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/js-pnp-single/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8342,7 +8335,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/ts-nm-individually/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8594,7 +8587,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/ts-nm-single/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8594,7 +8587,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/ts-pnp-individually/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8594,7 +8587,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
8 changes: 0 additions & 8 deletions test/__fixtures__/ts-pnp-single/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,6 @@ __metadata:
languageName: node
linkType: hard

"alphanum-sort@npm:^1.0.2":
version: 1.0.2
resolution: "alphanum-sort@npm:1.0.2"
checksum: 28bad91719e15959e36a791a3538924e07da356ebe3b5f992e7668e8018cfc417a7ba4a69512771e5ffa306c7e028435c7748546f66f72d4f7b0ad694cf55069
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.0
resolution: "ansi-align@npm:3.0.0"
Expand Down Expand Up @@ -8594,7 +8587,6 @@ fsevents@~2.3.1:
"@commitlint/cli": ^11.0.0
"@commitlint/config-conventional": ^11.0.0
"@vercel/nft": ^0.9.5
alphanum-sort: ^1.0.2
apr-find: ^3.0.3
apr-for-each: ^3.0.3
apr-intercept: ^3.0.4
Expand Down
22 changes: 10 additions & 12 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const PathIsInside = require('path-is-inside');
const { isSymlinkSync } = require('path-type');
const Reduce = require('apr-reduce');
const SortBy = require('lodash.sortby');
const Sort = require('alphanum-sort');
const Uniq = require('lodash.uniq');
const Setup = require('./setup');

Expand All @@ -29,18 +28,16 @@ const EVENT = {
};

const serializeTree = (children = []) => {
return Sort(
Uniq(
children.map(({ type, pathname, source }) => {
const link = source ? `-> ${source}` : '';
return `${type} ${pathname}${link}`;
}),
),
return Uniq(
children.map(({ type, pathname, source }) => {
const link = source ? `-> ${source}` : '';
return `${type} ${pathname}${link}`;
}),
);
};

const normalizeTree = ({ path: fullpath, type, children = [] }, root) => {
const pathname = relative(__dirname, fullpath);
const pathname = relative(root, fullpath);
const realpath = realpathSync(fullpath);
const isDiff = realpath !== fullpath;
const isInside = PathIsInside(realpath, root);
Expand All @@ -67,18 +64,19 @@ const normalizeTree = ({ path: fullpath, type, children = [] }, root) => {
: realpath;

const isSymlink = isSymlinkSync(fullpath);
const stat = lstatSync(fullpath);
const source = isSymlink
? readlinkSync(fullpath)
: hasSymlink && fullpath !== target
? relative(fullpath, target)
? relative(stat.isDirectory() ? fullpath : dirname(fullpath), target)
: null;

return SortBy(
Flatten(
children
.map((child) => normalizeTree(child, root))
.concat({ type, pathname, source }),
),
.concat([{ type, pathname, source }]),
).filter(({ pathname }) => pathname),
'pathname',
);
};
Expand Down

0 comments on commit 11ee91f

Please sign in to comment.