@g2d/core
Version:
Transform .gitignore to .dockerignore .
25 lines (21 loc) • 682 B
JavaScript
;
var detectNewline = require('detect-newline');
function g2b(input) {
var eol = detectNewline.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);
}
module.exports = g2b;