Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
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);
});
});
});
},
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
}
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 ?
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);
});
};
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())
"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");
module.exports = function() {
return [
'({',
' shouldDeps: [',
' ',
' ]',
'})',
''
].join(EOL);
};
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')
}
function format (lines) {
return EOL + lines.join(EOL) + EOL + EOL;
}