diff --git a/automation/build-bin.ts b/automation/build-bin.ts index 3e0e34bc..373951d7 100644 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -95,17 +95,18 @@ async function buildPkg() { await execPkg(args); - const xpaths: Array<[string, string[]]> = [ - // [platform, [path, to, file]] - ['*', ['open', 'xdg-open']], - ['darwin', ['denymount', 'bin', 'denymount']], + const paths: Array<[string, string[], string[]]> = [ + // [platform, [source path], [destination path]] + ['*', ['open', 'xdg-open'], ['xdg-open']], + ['darwin', ['denymount', 'bin', 'denymount'], ['denymount']], + ['win32', ['mmmagic', 'magic', 'magic.mgc'], ['mmmagic', 'magic.mgc']], ]; - await Bluebird.map(xpaths, ([platform, xpath]) => { + await Bluebird.map(paths, ([platform, source, dest]) => { if (platform === '*' || platform === process.platform) { - // eg copy from node_modules/opn/xdg-open to build-bin/xdg-open + // eg copy from node_modules/open/xdg-open to build-bin/xdg-open return fs.copy( - path.join(ROOT, 'node_modules', ...xpath), - path.join(ROOT, 'build-bin', xpath.pop()!), + path.join(ROOT, 'node_modules', ...source), + path.join(ROOT, 'build-bin', ...dest), ); } }); diff --git a/doc/cli.markdown b/doc/cli.markdown index 1efe19cf..1aaccd0d 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -1804,7 +1804,8 @@ left hand side of the = character will be treated as the variable name. #### --convert-eol, -l -Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified. +On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). +Source files are not modified. # Settings @@ -1933,7 +1934,7 @@ Path to a YAML or JSON file with passwords for a private Docker registry #### --convert-eol, -l -Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified. +On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified. #### --docker, -P <docker> @@ -2062,7 +2063,7 @@ Path to a YAML or JSON file with passwords for a private Docker registry #### --convert-eol, -l -Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified. +On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified. #### --docker, -P <docker> diff --git a/lib/actions/push.ts b/lib/actions/push.ts index 1fb8df02..5c27c6e6 100644 --- a/lib/actions/push.ts +++ b/lib/actions/push.ts @@ -248,7 +248,8 @@ export const push: CommandDefinition< signature: 'convert-eol', alias: 'l', description: stripIndent` - Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.`, + On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). + Source files are not modified.`, boolean: true, }, ], diff --git a/lib/utils/compose.coffee b/lib/utils/compose.coffee index b2a82ee6..b4a32af2 100644 --- a/lib/utils/compose.coffee +++ b/lib/utils/compose.coffee @@ -54,7 +54,9 @@ exports.appendOptions = (opts) -> }, { signature: 'convert-eol' - description: 'Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.' + description: ' + On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). + Source files are not modified.' boolean: true alias: 'l' } @@ -149,7 +151,11 @@ exports.tarDirectory = tarDirectory = (dir, { preFinalizeCallback, convertEol } streamToPromise = require('stream-to-promise') { FileIgnorer } = require('./ignore') { toPosixPath } = require('resin-multibuild').PathUtils - { readFileWithEolConversion } = require('./eol-conversion') + if process.platform == 'win32' + { readFileWithEolConversion } = require('./eol-conversion') + readFile = (file) -> readFileWithEolConversion(file, convertEol) + else + readFile = fs.readFile getFiles = -> streamToPromise(klaw(dir)) @@ -166,7 +172,7 @@ exports.tarDirectory = tarDirectory = (dir, { preFinalizeCallback, convertEol } .filter(ignore.filter) .map (file) -> relPath = path.relative(path.resolve(dir), file) - Promise.join relPath, fs.stat(file), readFileWithEolConversion(file, convertEol), + Promise.join relPath, fs.stat(file), readFile(file), (filename, stats, data) -> pack.entry({ name: toPosixPath(filename), size: stats.size, mode: stats.mode }, data) .then -> diff --git a/lib/utils/eol-conversion.ts b/lib/utils/eol-conversion.ts index 4c75990c..25c7fff0 100644 --- a/lib/utils/eol-conversion.ts +++ b/lib/utils/eol-conversion.ts @@ -92,11 +92,6 @@ export async function readFileWithEolConversion( ): Promise { const { fs } = await import('mz'); const fileBuffer = await fs.readFile(filepath); - - if (process.platform !== 'win32') { - return fileBuffer; - } - const Logger = await import('./logger'); const globalLogger = Logger.getLogger(); diff --git a/patches/mmmagic+0.5.3.patch b/patches/mmmagic+0.5.3.patch new file mode 100644 index 00000000..f3308218 --- /dev/null +++ b/patches/mmmagic+0.5.3.patch @@ -0,0 +1,14 @@ +diff --git a/node_modules/mmmagic/lib/index.js b/node_modules/mmmagic/lib/index.js +index bd18a4b..a19a149 100644 +--- a/node_modules/mmmagic/lib/index.js ++++ b/node_modules/mmmagic/lib/index.js +@@ -1,5 +1,8 @@ + var Magic = require('../build/Release/magic'); +-var fbpath = require('path').join(__dirname, '..', 'magic', 'magic'); ++var path = require('path'); ++var fbpath = process.pkg ++ ? path.join(path.dirname(process.execPath), 'mmmagic', 'magic') ++ : path.join(__dirname, '..', 'magic', 'magic'); + Magic.setFallback(fbpath); + + module.exports = {