Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@gulpjs/to-absolute-glob
Advanced tools
Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
@gulpjs/to-absolute-glob is an npm package that converts a given glob pattern to an absolute glob pattern. This is particularly useful in build systems and task runners like Gulp, where you need to work with file paths in a consistent manner.
Convert relative glob to absolute glob
This feature allows you to convert a relative glob pattern to an absolute glob pattern. The `cwd` option specifies the current working directory to resolve the relative path.
const toAbsoluteGlob = require('@gulpjs/to-absolute-glob');
const absoluteGlob = toAbsoluteGlob('./src/**/*.js', { cwd: process.cwd() });
console.log(absoluteGlob);
Handle negated globs
This feature supports negated glob patterns, which are used to exclude files from a set of matched files. The `!` character at the beginning of the glob pattern indicates negation.
const toAbsoluteGlob = require('@gulpjs/to-absolute-glob');
const absoluteGlob = toAbsoluteGlob('!./src/**/*.test.js', { cwd: process.cwd() });
console.log(absoluteGlob);
Options for handling different path formats
This feature allows you to specify additional options like `root` to handle different path formats. This can be useful when working in environments with different directory structures.
const toAbsoluteGlob = require('@gulpjs/to-absolute-glob');
const absoluteGlob = toAbsoluteGlob('./src/**/*.js', { cwd: process.cwd(), root: '/' });
console.log(absoluteGlob);
The `glob` package is a popular library for matching files using glob patterns. It provides extensive functionality for pattern matching and file searching, but it does not specifically focus on converting relative globs to absolute globs like @gulpjs/to-absolute-glob.
The `fast-glob` package is a high-performance glob library that supports advanced features like concurrency and caching. While it excels in performance and flexibility, it does not provide a direct method for converting relative globs to absolute globs.
The `minimatch` package is a minimalistic library for matching file paths against glob patterns. It is often used as a dependency in other glob-related packages. However, it does not offer functionality for converting relative globs to absolute globs.
Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
var toAbsoluteGlob = require('@gulpjs/to-absolute-glob');
// All these assume your cwd is `/dev/foo/`
toAbsoluteGlob('a/*.js') === '/dev/foo/a/*.js';
// Makes a path absolute
toAbsoluteGlob('a') === '/dev/foo/a';
// Retains trailing slashes
toAbsoluteGlob('a/*/') === '/dev/foo/a/*/';
// Makes a negative glob absolute
toAbsoluteGlob('!a/*.js') === '!/dev/foo/a/*.js';
// Accepts a cwd
toAbsoluteGlob('a/*.js', { cwd: 'foo' }) === '/dev/foo/foo/a/*.js';
// Accepts a root path
toAbsoluteGlob('/a/*.js', { root: 'baz' }) === '/dev/foo/baz/a/*.js';
toAbsoluteGlob(glob, [options])
Takes a glob
string and an optional options
object and produces an absolute glob. If the glob is relative, the root
or cwd
option (or process.cwd()
if neither specified) will be used as the base of the glob.
MIT
FAQs
Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
We found that @gulpjs/to-absolute-glob demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.