UNPKG

@g2d/core

Version:

Transform .gitignore to .dockerignore .

23 lines (20 loc) 659 B
import { detectNewline } from 'detect-newline'; function g2b(input) { var eol = detectNewline(input) || "\n"; return input .split(eol) .map(function (line) { if (!line || line.startsWith("#")) return line; var isNegative = line.startsWith("!"); var gitPath = isNegative ? line.slice(1) : line; var dockerPath = !gitPath ? "" : gitPath.startsWith("/") ? gitPath.slice(1) : "**/".concat(gitPath); return isNegative ? "!".concat(dockerPath) : dockerPath; }) .join(eol); } export { g2b as default };