Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/base

Package Overview
Dependencies
Maintainers
1
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/base - npm Package Compare versions

Comparing version 0.0.81 to 0.0.82

src/scan-app.ts

2

package.json

@@ -22,3 +22,3 @@ {

"scripts": {},
"version": "0.0.81"
"version": "0.0.82"
}
import { bulkRequire } from './scan-fs';
import { requireAppFiles } from './scan-app';

@@ -16,15 +17,7 @@ interface Initializer {

load(priority?: number) {
this.initializers =
bulkRequire<{ init: Initializer }>([
new RegExp(`phase[.]${this.scope}[.]ts$`)],
`${process.cwd()}/node_modules/@travetto`
).concat(
bulkRequire<{ init: Initializer }>([
new RegExp(`phase[.]${this.scope}[.]ts$`)
], `${process.cwd()}/phase`)
)
.map(x => x.init)
.map(x => ({ priority: PhaseManager.DEFAULT_PRIORITY, ...x }))
.filter(x => priority === undefined || x.priority <= priority)
.sort((a, b) => a.priority - b.priority);
this.initializers = requireAppFiles('.ts', new RegExp(`phase[.]${this.scope}[.]ts$`))
.map(x => x.init)
.map(x => ({ priority: PhaseManager.DEFAULT_PRIORITY, ...x }))
.filter(x => priority === undefined || x.priority <= priority)
.sort((a, b) => a.priority - b.priority);
}

@@ -31,0 +24,0 @@

@@ -16,3 +16,6 @@ import * as path from 'path';

export type Handler = { test: (relative: string, entry?: Entry) => boolean };
export type Handler = {
testFile?: (relative: string, entry?: Entry) => boolean,
testDir?: (relative: string, entry?: Entry) => boolean
};

@@ -36,2 +39,3 @@ export async function bulkFind(handlers: Handler[], base?: string) {

return new Promise<Entry[]>(async (resolve, reject) => {
try {

@@ -53,8 +57,10 @@ const out: Entry[] = [];

if (stats.isDirectory()) {
entry.children = await scanDir(handler, base, full);
out.push(entry);
if (entry.children.length) {
out.push(...entry.children);
if (!handler.testDir || handler.testDir(entry.file.replace(base + path.sep, ''), entry)) {
entry.children = await scanDir(handler, base, full);
out.push(entry);
if (entry.children.length) {
out.push(...entry.children);
}
}
} else if (handler.test(entry.file.replace(base + path.sep, ''), entry)) {
} else if (!handler.testFile || handler.testFile(entry.file.replace(base + path.sep, ''), entry)) {
out.push(entry);

@@ -100,8 +106,10 @@ }

if (stats.isDirectory()) {
entry.children = scanDirSync(handler, base, full);
out.push(entry);
if (entry.children.length) {
out.push(...entry.children);
if (!handler.testDir || handler.testDir(entry.file.replace(base + path.sep, ''), entry)) {
entry.children = scanDirSync(handler, base, full);
out.push(entry);
if (entry.children.length) {
out.push(...entry.children);
}
}
} else if (handler.test(entry.file.replace(base + path.sep, ''))) {
} else if (!handler.testFile || handler.testFile(entry.file.replace(base + path.sep, ''))) {
out.push(entry);

@@ -135,3 +143,3 @@ }

export async function rimraf(pth: string) {
const files = await scanDir(/.*/, pth);
const files = await scanDir({}, pth);
for (const filter of [

@@ -138,0 +146,0 @@ (x: Entry) => !x.stats.isDirectory(),

@@ -77,3 +77,3 @@ import * as util from 'util';

this.findHandlers = this.findHandlers.concat(handlers.map(x => {
return typeof x === 'string' ? { test: (rel: string) => rel === x } : x;
return typeof x === 'string' ? { testFile: (rel: string) => rel === x } : x;
}));

@@ -156,3 +156,4 @@

if (!prevSet.has(next) && (nextStats.isDirectory() || this.findHandlers.find(x => x.test(nextRel)))) {
if (!prevSet.has(next) && (nextStats.isDirectory() ||
this.findHandlers.find(x => x.testFile ? x.testFile(nextRel) : false))) {
const sub: Entry = {

@@ -159,0 +160,0 @@ file: next,

require('../bin/travetto').run().then(x => {
// require('./stack');
require('./stack');
// require('./watch');
// require('./merge');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc