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

@after-work.js/utils

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@after-work.js/utils - npm Package Compare versions

Comparing version 5.1.1 to 6.0.0-dev.20181219.0

11

package.json
{
"name": "@after-work.js/utils",
"version": "5.1.1",
"version": "6.0.0-dev.20181219.0",
"publishConfig": {

@@ -25,3 +25,10 @@ "access": "public"

],
"gitHead": "437b47d84de1baec6ce8e7810c9b8d519c41a70a"
"dependencies": {
"debug": "4.0.1",
"globby": "8.0.1",
"import-cwd": "2.1.0",
"minimatch": "3.0.4",
"npmlog": "4.1.2"
},
"gitHead": "ae9f1ec01c01df3a23b2c65c5a070c2cde1ffb76"
}

@@ -6,6 +6,84 @@ /* eslint max-len: 0, import/no-dynamic-require: 0, global-require: 0 */

const importCwd = require('import-cwd');
const debug = require('debug');
const globby = require('globby');
const minimatch = require('minimatch');
const isCI = !!process.env.CI;
const pkg = importCwd('./package.json');
const findPkgs = g => globby.sync(`${g}/package.json`);
const reducePkgs = (acc, curr) => acc.concat(curr.map(c => c.slice(0, -13)));
const lerna = importCwd.silent('./lerna.json');
const workspaces = (pkg.workspaces || []).map(findPkgs).reduce(reducePkgs, []);
const lernaPackages = ((lerna && lerna.packages) || [])
.map(findPkgs)
.reduce(reducePkgs, []);
const packagesPath = [...workspaces, ...lernaPackages];
let packages = [];
const packagesMap = new Map();
packagesPath.forEach((root) => {
const { name } = importCwd(`./${root}/package.json`);
packages = [...packages, name];
packagesMap.set(name, root);
});
const DEFAULT_TEST_EXT_PATTERN = '*.{spec,test}.{js,ts}';
const DEFAULT_TEST_GLOB_PATTERN = `**/${DEFAULT_TEST_EXT_PATTERN}`;
const DEFAULT_SRC_EXT_PATTERN = '*.{js,ts}';
const DEFAULT_SRC_GLOB_PATTERN = `**/${DEFAULT_SRC_EXT_PATTERN}`;
const DEFAULT_SRC_EXCLUDE_PATTERN = [
'**/coverage/**',
'**/scripts/**',
'**/docs/**',
'**/tools/**',
'**/__*__/**',
'**/test/**',
'**/mocks/**',
'**/dist/**',
`**/${DEFAULT_TEST_EXT_PATTERN}`,
'**/*.config.*',
];
const TEST_GLOB = [
...(packagesPath.length
? packagesPath.map(p => `${p}/${DEFAULT_TEST_GLOB_PATTERN}`)
: [DEFAULT_TEST_GLOB_PATTERN]),
'!**/node_modules/**',
'!./node_modules/**',
];
const SRC_GLOB = [
...(packagesPath.length
? packagesPath.map(p => `${p}/${DEFAULT_SRC_GLOB_PATTERN}`)
: [DEFAULT_SRC_GLOB_PATTERN]),
'!**/node_modules/**',
'!./node_modules/**',
];
const WATCH_GLOB = [...TEST_GLOB, ...SRC_GLOB];
const DEFAULT_TRANSFORM_EXCLUDE_PATTERN = [
'**/node_modules/**',
'./node_modules/**',
'**/coverage/**',
'**/external/**',
'**/autogenerated/**',
'**/*.{html,css,json,txt,ttf,woff,svg,ico}',
'**/*require*.js',
'**/*sinon*.js',
'**/*chai*.js',
];
const DEFAULT_INSTRUMENT_EXCLUDE_PATTERN = DEFAULT_TRANSFORM_EXCLUDE_PATTERN;
const utils = {
packages,
packagesPath,
packagesMap,
workspaces,
lernaPackages,
DEFAULT_TEST_EXT_PATTERN,
DEFAULT_TEST_GLOB_PATTERN,
DEFAULT_SRC_GLOB_PATTERN,
DEFAULT_SRC_EXCLUDE_PATTERN,
TEST_GLOB,
SRC_GLOB,
WATCH_GLOB,
DEFAULT_TRANSFORM_EXCLUDE_PATTERN,
DEFAULT_INSTRUMENT_EXCLUDE_PATTERN,
isSourceMap(f) {

@@ -27,24 +105,21 @@ return !fs.existsSync(f) && f.endsWith('.map');

ensureFilePath(js) {
if (!fs.existsSync(js) && js.endsWith('.js')) {
const exists = fs.existsSync(js);
if (!exists && js.endsWith('.js')) {
const ts = utils.getPathWithExt(js, 'ts');
if (!fs.existsSync(ts)) {
throw new Error(`Can't find file ${js}`);
return '';
}
return ts;
}
return js;
return exists ? js : '';
},
clearLine() {
if (isCI) {
return;
}
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
readline.clearLine(process.stderr, 0);
readline.cursorTo(process.stderr, 0, null);
},
writeLine(msg) {
if (isCI) {
return;
}
writeLine(prefix, msg) {
this.clearLine();
process.stdout.write(`${msg}`);
process.stderr.write(
`${prefix} ${msg.length > 60 ? '...' : ''}${msg.slice(-59)}`,
);
},

@@ -76,6 +151,8 @@ safeGetModule(name) {

if (typeof opt.babelPluginIstanbul === 'string') {
opt.babelPluginIstanbul = importCwd(opt.babelPluginIstanbul).default;
opt.babelPluginIstanbul = utils.safeGetModule(
opt.babelPluginIstanbul,
).default;
}
if (typeof opt.typescript === 'string') {
opt.typescript = importCwd.silent(opt.typescript);
opt.typescript = utils.safeGetModule(opt.typescript);
}

@@ -96,3 +173,3 @@ return opt;

const filename = path.resolve(parts.join(':'));
return [filename, lineno, columnno];
return [filename, lineno, columnno, c];
})

@@ -122,3 +199,5 @@ .filter(([filename]) => testFiles.indexOf(filename) !== -1);

return require.cache[f];
} catch (_) { } //eslint-disable-line
} catch (_) {
// console.error(_)
}
return { children: [] };

@@ -129,3 +208,8 @@ },

if (found.length > 1) {
const matchName = found.filter(id => path.basename(id).split('.').shift() === testName);
const matchName = found.filter(
id => path
.basename(id)
.split('.')
.shift() === testName,
);
if (matchName.length === 1) {

@@ -140,6 +224,8 @@ use = matchName;

getDependencies(files, file) {
const name = path.basename(file).split('.').shift();
const name = path
.basename(file)
.split('.')
.shift();
const mod = this.safeRequireCache(file);
const found = mod
.children
const found = mod.children
.filter(m => files.indexOf(m.id) !== -1)

@@ -162,4 +248,17 @@ .map(m => m.id);

},
createDebug(p) {
return debug(`@after-work.js:${p}`);
},
filter(arr, initialValue) {
return arr.reduce(
(acc, curr) => acc.filter(file => minimatch(file, curr)),
initialValue,
);
},
isMatchingExtPattern(filePath, extPattern) {
const base = path.basename(filePath);
return minimatch(base, extPattern);
},
};
module.exports = utils;
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