How to use the os.EOL function in os

To help you get started, we’ve selected a few os 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 ditojs / dito / packages / server / src / utils / string.js View on Github external
const str = parts.join('')
  const lines = str.split(/\r\n|\n|\r/)
  // Remove the first line-break at the beginning of the result, to allow this:
  // const value = `
  //   content...
  //   ` // line break at the end remains
  if (!lines[0]) lines.shift()
  let indent = Infinity
  for (const line of lines) {
    const match = line.match(/^(\s*)\S+/)
    if (match) {
      indent = Math.min(indent, match[1].length)
    }
  }
  return indent > 0
    ? lines.map(line => line.slice(indent)).join(os.EOL)
    : str
}
github NuSkooler / enigma-bbs / core / file_transfer.js View on Github external
temptmp.open( { prefix : TEMP_SUFFIX, suffix : '.txt' }, (err, tempFileInfo) => {
                        if(err) {
                            return callback(err);   //  failed to create it
                        }

                        fs.write(tempFileInfo.fd, filePaths.join(SYSTEM_EOL), err => {
                            if(err) {
                                return callback(err);
                            }
                            fs.close(tempFileInfo.fd, err => {
                                return callback(err, tempFileInfo.path);
                            });
                        });
                    });
                },
github Pomegranate / Pomegranate / bin / templates / pluginSettingsObject.js View on Github external
module.exports = function(pluginName, exportObj) {
  var objString = stringifyObject(exportObj, {indent: '  ', singleQuotes: true})
  objString = 'exports.'+ pluginName +' = ' + objString + ';';

  var EOL = require('os').EOL
  var file = [
    '/* ',
    ' * ' + pluginName + ' -- Settings',
    ' */',
    ''
  ].concat(objString).join(EOL)
  return file
}
github jakubpawlowicz / clean-css / lib / text / expressions-processor.js View on Github external
var breaksCount;
  var lastBreakAt;
  var newIndent;
  var saveWaypoints = this.saveWaypoints;

  for (; nextEnd < data.length;) {
    nextStart = data.indexOf(EXPRESSION_PREFIX, nextEnd);
    if (nextStart == -1)
      break;

    nextEnd = findEnd(data, nextStart);

    var expression = data.substring(nextStart, nextEnd);
    if (saveWaypoints) {
      breaksCount = expression.split(lineBreak).length - 1;
      lastBreakAt = expression.lastIndexOf(lineBreak);
      newIndent = lastBreakAt > 0 ?
        expression.substring(lastBreakAt + lineBreak.length).length :
        indent + expression.length;
    }

    var metadata = saveWaypoints ? [breaksCount, newIndent] : null;
    var placeholder = this.expressions.store(expression, metadata);
    tempData.push(data.substring(cursor, nextStart));
    tempData.push(placeholder);

    if (saveWaypoints)
      indent = newIndent + 1;
    cursor = nextEnd;
  }

  return tempData.length > 0 ?
github biosustain / ancestry / jspm_packages / npm / clean-css@3.4.18 / lib / text / free-text-processor.js View on Github external
return new QuoteScanner(data).each(function(match, store) {
      if (saveWaypoints) {
        breaksCount = match.split(lineBreak).length - 1;
        lastBreakAt = match.lastIndexOf(lineBreak);
        indent = lastBreakAt > 0 ? match.substring(lastBreakAt + lineBreak.length).length : match.length;
        metadata = [breaksCount, indent];
      }
      var placeholder = self.matches.store(match, metadata);
      store.push(placeholder);
    });
  };
github vendure-ecommerce / vendure / packages / create / src / create-vendure-app.ts View on Github external
return new Observable(subscriber => {
                    subscriber.next('Creating package.json');
                    fs.writeFileSync(
                        path.join(root, 'package.json'),
                        JSON.stringify(packageJsonContents, null, 2) + os.EOL,
                    );
                    const { dependencies, devDependencies } = getDependencies(
                        usingTs,
                        dbType,
                        isCi ? `@${packageJson.version}` : '',
                    );

                    subscriber.next(`Installing ${dependencies.join(', ')}`);
                    installPackages(root, useYarn, dependencies, false, logLevel, isCi)
                        .then(() => {
                            if (devDependencies.length) {
                                subscriber.next(`Installing ${devDependencies.join(', ')}`);
                                return installPackages(root, useYarn, devDependencies, true, logLevel);
                            }
                        })
                        .then(() => subscriber.complete())
github HadoukenIO / symphony-of / build.js View on Github external
"manifest.js",
    "screensnippet.js",
    "main.js",
    "utils.js",
    "events.js",
    "download-bar.js"
];

let fileContents = [
  '/*',
  '* WARNING: This file is auto-generated, any changes made to this',
  '*          file will be overwritten by the build script!',
  '*/',
  '',
  `window.fin.symphony = ${JSON.stringify({version, revision, settings}, null, 2)};`
].join(newLine) + newLine;

fileContents += buildFiles
  .map(filePath => [
    '/*',
    '* --------------------------------',
    `* ${filePath}`,
    '* --------------------------------',
    '*/',
    '',
    fs.readFileSync(path.join(jsDir, filePath), "utf8")
    ].join(newLine))
  .join(newLine);

const bundlePath = path.join(publicDir, "bundle.js");

fs.writeFileSync(bundlePath, fileContents, "utf8");
github bem-tools / bem-tools-create / lib / templates / deps.js.js View on Github external
module.exports = function() {
    return [
        '({',
        '    shouldDeps: [',
        '        ',
        '    ]',
        '})',
        ''
    ].join(EOL);
};
github mockingbot / ibot / build / build-lib.js View on Github external
function renderIndexFile (pkgs) {
  const importStatmentsArray = []
  for (let i = 0; i < pkgs.length; i++) {
    const pkg = pkgs[i]
    const camelCasedPkg = camelCase(pkg)
    importStatmentsArray.push(
      render(tmpl, {
        name: ['util', 'form', 'text'].includes(pkg) ? camelCasedPkg : capitalize(camelCasedPkg),
        package: pkg
      })
    )
  }

  const importStatments = importStatmentsArray.splice(',').join(endOfLine)

  fs.writeFileSync(`${libDir}/index.js`, importStatments)

  fs.writeFileSync(`${libDir}/index.js`, babel.transformFileSync(`${libDir}/index.js`).code, 'utf8')
}
github codemanki / cloudscraper / errors.js View on Github external
function format (lines) {
  return EOL + lines.join(EOL) + EOL + EOL;
}