@cplace/cli
Advanced tools
Comparing version 0.19.20 to 0.19.21
@@ -22,2 +22,3 @@ import { ICommand, ICommandParameters } from '../models'; | ||
protected writeNewParentRepos(newParentRepos: IReposDescriptor): Promise<void>; | ||
protected convertLineEndings(content: string): string; | ||
} |
@@ -18,5 +18,5 @@ "use strict"; | ||
const fs = require("fs"); | ||
const util_1 = require("../../util"); | ||
const path = require("path"); | ||
const rimraf = require("rimraf"); | ||
const eol = require("eol"); | ||
class AbstractReposCommand { | ||
@@ -88,3 +88,4 @@ prepareAndMayExecute(params, rootDir) { | ||
writeNewParentRepos(newParentRepos) { | ||
const newParentReposContent = util_1.enforceNewline(JSON.stringify(newParentRepos, null, 2)); | ||
const jsonContent = JSON.stringify(newParentRepos, null, 2); | ||
const newParentReposContent = this.convertLineEndings(`${jsonContent}\n`); | ||
Global_1.Global.isVerbose() && console.log('new repo description', newParentReposContent); | ||
@@ -95,2 +96,9 @@ fs.writeFileSync(this.parentReposConfigPath, newParentReposContent, 'utf8'); | ||
} | ||
convertLineEndings(content) { | ||
const isWindows = process.platform === 'win32'; | ||
if (isWindows) { | ||
return eol.crlf(content); | ||
} | ||
return content; | ||
} | ||
} | ||
@@ -97,0 +105,0 @@ exports.AbstractReposCommand = AbstractReposCommand; |
@@ -132,4 +132,4 @@ "use strict"; | ||
let blockStartFound = false; | ||
let blockEndFound = false; | ||
let bracketLevel = 0; | ||
let blockStartIndex = 0; | ||
const blockReplace = `${blockName}\\s*\\{`; | ||
@@ -139,5 +139,6 @@ const blockRegex = new RegExp(blockReplace, 'g'); | ||
const line = buildFileContent[this.currentReadIndex]; | ||
if (!blockStartFound || blockEndFound) { | ||
if (!blockStartFound) { | ||
if (line.trim().match(blockRegex)) { | ||
blockStartFound = true; | ||
blockStartIndex = this.currentReadIndex; | ||
bracketLevel++; | ||
@@ -158,3 +159,9 @@ } | ||
if (bracketLevel === 0) { | ||
blockEndFound = true; | ||
// reset, for a possible second block | ||
blockStartFound = false; | ||
// skip one line if there are empty lines before and after the block, so we don't end up with two empty lines | ||
if (result.length > 0 && this.currentReadIndex < buildFileContent.length - 1 && | ||
result[result.length - 1].trim() === '' && buildFileContent[this.currentReadIndex + 1].trim() === '') { | ||
this.currentReadIndex++; | ||
} | ||
} | ||
@@ -167,10 +174,4 @@ } | ||
createStringFromContentArray(content) { | ||
let lineEnding = '\n'; | ||
const isWindows = process.platform === 'win32'; | ||
if (process.platform === 'win32') { | ||
lineEnding = '\r\n'; | ||
} | ||
let result = ''; | ||
content.forEach((line) => result += line + lineEnding); | ||
return result; | ||
const result = content.join('\n'); | ||
return this.convertLineEndings(result); | ||
} | ||
@@ -177,0 +178,0 @@ } |
{ | ||
"name": "@cplace/cli", | ||
"version": "0.19.20", | ||
"version": "0.19.21", | ||
"description": "cplace cli tools", | ||
@@ -51,2 +51,3 @@ "main": "dist/index.js", | ||
"cpr": "^3.0.1", | ||
"eol-converter-cli": "^1.0.8", | ||
"meow": "^7.0.1", | ||
@@ -53,0 +54,0 @@ "randomatic": "^3.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
482121
6426
9
+ Addedeol-converter-cli@^1.0.8
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedeol@0.9.1(transitive)
+ Addedeol-converter-cli@1.1.0(transitive)
+ Addedglob@9.3.5(transitive)
+ Addedlru-cache@10.4.3(transitive)
+ Addedminimatch@8.0.4(transitive)
+ Addedminipass@4.2.87.1.2(transitive)
+ Addedpath-scurry@1.11.1(transitive)