How to use the resin-multibuild.PathUtils function in resin-multibuild

To help you get started, we’ve selected a few resin-multibuild 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 balena-io / balena-cli / lib / utils / compose_ts.ts View on Github external
export function validateSpecifiedDockerfile(
	projectPath: string,
	dockerfilePath: string = '',
): string {
	if (!dockerfilePath) {
		return dockerfilePath;
	}
	const { isAbsolute, join, normalize, parse, posix } = require('path');
	const { existsSync } = require('fs');
	const { contains, toNativePath, toPosixPath } = MultiBuild.PathUtils;

	// reminder: native windows paths may start with a drive specificaton,
	// e.g. 'C:\absolute' or 'C:relative'.
	if (isAbsolute(dockerfilePath) || posix.isAbsolute(dockerfilePath)) {
		exitWithExpectedError(stripIndent`
			Error: absolute Dockerfile path detected:
			"${dockerfilePath}"
			The Dockerfile path should be relative to the source folder.
		`);
	}
	const nativeProjectPath = normalize(projectPath);
	const nativeDockerfilePath = join(projectPath, toNativePath(dockerfilePath));

	if (!contains(nativeProjectPath, nativeDockerfilePath)) {
		// Note that testing the existence of nativeDockerfilePath in the
		// filesystem (after joining its path to the source folder) is not
github balena-io / balena-cli / lib / utils / ignore.ts View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import * as _ from 'lodash';
import { fs } from 'mz';
import * as path from 'path';
import * as MultiBuild from 'resin-multibuild';

import dockerIgnore = require('@zeit/dockerignore');
import ignore from 'ignore';

const { toPosixPath } = MultiBuild.PathUtils;

export enum IgnoreFileType {
	DockerIgnore,
	GitIgnore,
}

interface IgnoreEntry {
	pattern: string;
	// The relative file path from the base path of the build context
	filePath: string;
}

export class FileIgnorer {
	private dockerIgnoreEntries: IgnoreEntry[];
	private gitIgnoreEntries: IgnoreEntry[];