How to use the liferay-npm-build-tools-common/lib/file-path 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 / babel-plugin-alias-modules / src / index.ts View on Github external
if (absSearchDir.is(_absRootDir)) {
			return undefined;
		}

		// Look up in hierachy
		alias = this._getAliasForExternal(
			absSearchDir.dirname(),
			requiredModule
		);

		// Rebase to current folder
		if (
			alias !== undefined &&
			getAliasToType(alias) === AliasToType.LOCAL
		) {
			alias = new FilePath(`../${alias}`, {posix: true}).normalize()
				.asPosix;
		}

		return alias;
	}
github liferay / liferay-js-toolkit / packages / liferay-npm-imports-checker / src / liferay-npm-imports-checker.js View on Github external
return;
				}

				const {npmbundlerrc} = new Project(pkgJsonDir);

				if (npmbundlerrc.config && npmbundlerrc.config.imports) {
					npmbundlerrc.config.imports = normalizeImportsConfig(
						npmbundlerrc.config.imports,
						true
					);
				}

				projects[pkgJson.name] = {
					name: pkgJson.name,
					dir: new FilePath(pkgJsonDir),
					pkgJson,
					npmbundlerrc,
				};

				_msg(1, pkgJsonDir);
			} catch (err) {
				// Swallow.
			}
		});
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-plugin-replace-browser-modules / src / index.ts View on Github external
`/* redirected by alias field(s) in ${rootRelAbsDirPosixPath} */`,
						`module.exports = require('${alias.to}');`
					);

					log.info(
						'replace-browser-modules',
						`Redirected file '${rootRelFilePosixPath}' to ` +
							`'${alias.to}' as configured in ` +
							`'${rootRelAbsDirPosixPath}'`
					).linkToCode(2);
					break;
				}

				case AliasToType.LOCAL: {
					const absToFile = alias.absDir.join(
						new FilePath(alias.to as string, {posix: true})
					);
					const fromRelToFile = absFromFile
						.dirname()
						.relative(absToFile);

					rewriteFile(
						absFromFile,
						`/* redirected by alias field(s) in ${rootRelAbsDirPosixPath} */`,
						`module.exports = require('./${fromRelToFile.asPosix}');`
					);

					log.info(
						'replace-browser-modules',
						`Redirected file '${rootRelFilePosixPath}' to ` +
							`'./${fromRelToFile.asPosix}' as configured in ` +
							`'${rootRelAbsDirPosixPath}'`
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / steps / util.js View on Github external
		.map(baseDirRelPath => new FilePath(baseDirRelPath, {posix: true}));
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler-loader-css-loader / src / index.js View on Github external
});

	if (extension !== undefined) {
		const extname = path.extname(filePath);

		if (extname == '') {
			filePath = `${filePath}.${extension}`;
		} else {
			filePath = filePath.replace(
				new RegExp(`\\${extname}$`),
				`${extension}`
			);
		}
	}

	filePath = new FilePath(filePath).asPosix;

	return `${pathModule}${webContextPath}/${filePath}`;
}
github liferay / liferay-js-toolkit / packages / liferay-npm-build-support / src / loader / wrap-webpack-bundle.ts View on Github external
function getModuleName(prjRelfilePath: string, removePrefix: string): string {
	const absFile = new FilePath(prjRelfilePath);
	const pkgDir = new FilePath(babelUtil.getPackageDir(prjRelfilePath));

	let moduleName: string = pkgDir.relative(absFile).asPosix;

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

	if (moduleName.startsWith(removePrefix)) {
		moduleName = moduleName.substring(removePrefix.length);
	}

	const pkgJson = readJsonSync(pkgDir.join('package.json').asNative);

	return `${pkgJson.name}@${pkgJson.version}/${moduleName}`;
}