How to use the liferay-npm-build-tools-common/lib/packages.getPackageDir function in liferay-npm-build-tools-common

To help you get started, we’ve selected a few liferay-npm-build-tools-common 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 liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / config / index.js View on Github external
presetFile = require.resolve('liferay-npm-bundler-preset-standard');
	} else if (config.preset === '' || config.preset === false) {
		// don't load preset
	} else {
		presetFile = resolveModule.sync(config.preset, {
			basedir: '.',
		});
	}

	if (presetFile) {
		const originalConfig = Object.assign({}, config);
		Object.assign(
			config,
			merge.recursive(readJsonSync(presetFile), originalConfig)
		);
		config.pluginsBaseDir = getPackageDir(presetFile);
	}

	// Normalize
	config['/'] = config['/'] || {};
	config['config'] = config['config'] || {};
	config.packages = config.packages || {};
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / config.js View on Github external
config = readJsonSync('.npmbundlerrc');
	} catch (err) {
		if (err.code !== 'ENOENT') {
			throw err;
		}
	}

	// Apply preset if necessary
	if (config.preset) {
		const presetFile = resolveModule.sync(config.preset, {
			basedir: '.',
		});

		// Merge preset with base configuration
		config = Object.assign(readJsonSync(presetFile), config);
		pluginsBaseDir = getPackageDir(presetFile);
	}

	// Normalize
	config.packages = config.packages || {};

	return config;
}
github liferay / liferay-js-toolkit / packages / babel-plugin-name-amd-modules / src / index.js View on Github external
function getModuleName(filenameRelative, srcPrefixes) {
	const filenameAbsolute = path.resolve(filenameRelative);
	const pkgDir = pkgs.getPackageDir(filenameRelative);

	let moduleName = filenameAbsolute.substring(pkgDir.length + 1);

	if (moduleName.toLowerCase().endsWith('.js')) {
		moduleName = moduleName.substring(0, moduleName.length - 3);
	}

	for (let i = 0; i < srcPrefixes.length; i++) {
		const srcPrefix = path.normalize(srcPrefixes[i]);

		if (moduleName.startsWith(srcPrefix)) {
			moduleName = moduleName.substring(srcPrefix.length);
			break;
		}
	}
github liferay / liferay-js-toolkit / packages / babel-plugin-shim-nodejs / src / node / globals.js View on Github external
__filename: function(filePath) {
		const pkgDir = getPackageDir(filePath);

		let filename = filePath.substring(pkgDir.length + 1);

		return `var __filename = '/${filename}';`;
	},
	clearImmediate: 'require("liferay-node-setimmediate");',