mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
On Win32, write out default .hyper.js as CRLF so Notepad doesn't have a fit (#1383)
* On Win32, write out default .hyper.js as CRLF so Notepad doesn't have a fit * Fix hwhoops * Add explanatory comment
This commit is contained in:
parent
b4943a05e9
commit
2670b17872
1 changed files with 12 additions and 2 deletions
|
|
@ -84,6 +84,13 @@ function exec(str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method will take text formatted as Unix line endings and transform it
|
||||||
|
// to text formatted with DOS line endings. We do this because the default
|
||||||
|
// text editor on Windows (notepad) doesn't Deal with LF files. Still. In 2017.
|
||||||
|
function crlfify(str) {
|
||||||
|
return str.split('\n').map(x => x.indexOf('\r') < 0 ? x : `${x}\r`).join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
exports.subscribe = function (fn) {
|
exports.subscribe = function (fn) {
|
||||||
watchers.push(fn);
|
watchers.push(fn);
|
||||||
return () => {
|
return () => {
|
||||||
|
|
@ -110,9 +117,12 @@ exports.init = function () {
|
||||||
try {
|
try {
|
||||||
console.log('attempting to write default config to', path);
|
console.log('attempting to write default config to', path);
|
||||||
exec(defaultConfig);
|
exec(defaultConfig);
|
||||||
writeFileSync(path, defaultConfig);
|
|
||||||
|
writeFileSync(
|
||||||
|
path,
|
||||||
|
process.platform === 'win32' ? crlfify(defaultConfig.toString()) : defaultConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Failed to write config to ${path}`);
|
throw new Error(`Failed to write config to ${path}: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch();
|
watch();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue