How to use the liferay-npm-build-tools-common/lib/packages.getPackageTargetDir 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 / steps / transform.js View on Github external
function renamePkgDirIfNecessary(destPkg) {
	if (destPkg.isRoot) {
		return Promise.resolve(destPkg);
	}

	const pkgJson = readJsonSync(destPkg.dir.join('package.json').asNative);
	const outputDirPath = path.dirname(destPkg.dir.asNative);

	if (pkgJson.name !== destPkg.name || pkgJson.version !== destPkg.version) {
		const newDirPath = path.join(
			outputDirPath,
			getPackageTargetDir(pkgJson.name, pkgJson.version)
		);

		rimraf.sync(newDirPath);

		return fs
			.move(destPkg.dir.asNative, newDirPath)
			.then(() => new PkgDesc(pkgJson.name, pkgJson.version, newDirPath));
	}

	return Promise.resolve(destPkg);
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-plugin-inject-angular-dependencies / src / index.js View on Github external
deps.forEach(dep => {
		let dirPrefix;

		if (dep.indexOf('/') != -1) {
			dirPrefix = `${getPackageTargetDir(dep)}@`;
		} else {
			dirPrefix = `${dep}@`;
		}

		if (!pkgJson.dependencies[dep]) {
			const nodeModulesDir = path.resolve(path.join(pkg.dir, '..'));

			for (let dir of fs.readdirSync(nodeModulesDir)) {
				if (dir.startsWith(dirPrefix)) {
					const depPkgJson = readJsonSync(
						path.join(nodeModulesDir, dir, 'package.json')
					);

					pkgJson.dependencies[dep] = depPkgJson.version;

					log.info(
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / util.js View on Github external
export function renamePkgDirIfPkgJsonChanged(pkg) {
	const pkgJson = readJsonSync(path.join(pkg.dir, 'package.json'));
	const outputDir = path.dirname(pkg.dir);

	if (pkgJson.name !== pkg.name || pkgJson.version !== pkg.version) {
		const newDir = path.join(
			outputDir,
			getPackageTargetDir(pkgJson.name, pkgJson.version)
		);

		return fs
			.move(pkg.dir, newDir)
			.then(
				() =>
					new PkgDesc(
						pkgJson.name,
						pkgJson.version,
						newDir,
						pkg.isRoot
					)
			);
	}

	return Promise.resolve(pkg);
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / util.js View on Github external
export function getDestDir(pkg) {
	return pkg.isRoot
		? project.dir.join(project.buildDir).asNative
		: project.buildDir.join(
				'node_modules',
				getPackageTargetDir(pkg.name, pkg.version)
		  ).asNative;
}