How to use the micromatch.capture function in micromatch

To help you get started, we’ve selected a few micromatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swashata / wp-webpack-script / site / gatsby-node.js View on Github external
exports.onCreateNode = ({ node, actions, getNode }) => {
	const { createNodeField } = actions;

	if (node.internal.type === `MarkdownRemark`) {
		const value = createFilePath({ node, getNode });
		createNodeField({
			name: `slug`,
			node,
			value,
		});
		// Create additional fields if it is a part of docs
		if (mm.isMatch(node.fileAbsolutePath, '**/docs/*/*.md')) {
			const type = mm.capture(
				`${__dirname}/docs/*/*.md`,
				node.fileAbsolutePath
			);
			if (type && type[0]) {
				createNodeField({
					name: 'docType',
					node,
					value: type[0],
				});
			}
		}
	}
};
github yeojz / babel-plugin-transform-assets-import-to-string / src / mutliTransform.js View on Github external
options.rules.some(rule => {
    const result = mm.capture(rule.pattern, filepath, options.matchOptions);
    if (!result) {
      return false;
    }
    const value = interpolate(rule.to, result);
    replaceNode(scope, options.baseUri + value);
    return true;
  });
}

micromatch

Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis