Bump csv-parse from 4.14.2 to 4.15.1 (#42)

* Bump csv-parse from 4.14.2 to 4.15.1

Bumps [csv-parse](https://github.com/wdavidw/node-csv-parse) from 4.14.2 to 4.15.1.
- [Release notes](https://github.com/wdavidw/node-csv-parse/releases)
- [Changelog](https://github.com/adaltas/node-csv-parse/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wdavidw/node-csv-parse/compare/v4.14.2...v4.15.1)

Signed-off-by: dependabot[bot] <support@github.com>

* Update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2021-02-03 18:11:37 +00:00 committed by GitHub
parent cae03854eb
commit 94e634192d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 40 deletions

93
dist/index.js generated vendored
View File

@ -4240,10 +4240,14 @@ additional information.
const { Transform } = __webpack_require__(2413) const { Transform } = __webpack_require__(2413)
const ResizeableBuffer = __webpack_require__(6942) const ResizeableBuffer = __webpack_require__(6942)
// white space characters
// https://en.wikipedia.org/wiki/Whitespace_character
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes#Types
// \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff
const tab = 9 const tab = 9
const nl = 10 const nl = 10 // \n, 0x0A in hexadecimal, 10 in decimal
const np = 12 const np = 12
const cr = 13 const cr = 13 // \r, 0x0D in hexadécimal, 13 in decimal
const space = 32 const space = 32
const boms = { const boms = {
// Note, the following are equals: // Note, the following are equals:
@ -4432,6 +4436,27 @@ class Parser extends Transform {
throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(opts.from_line)}`) throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(opts.from_line)}`)
} }
} }
// Normalize options `ignore_last_delimiters`
if(options.ignore_last_delimiters === undefined || options.ignore_last_delimiters === null){
options.ignore_last_delimiters = false
}else if(typeof options.ignore_last_delimiters === 'number'){
options.ignore_last_delimiters = Math.floor(options.ignore_last_delimiters)
if(options.ignore_last_delimiters === 0){
options.ignore_last_delimiters = false
}
}else if(typeof options.ignore_last_delimiters !== 'boolean'){
throw new CsvError('CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS', [
'Invalid option `ignore_last_delimiters`:',
'the value must be a boolean value or an integer,',
`got ${JSON.stringify(options.ignore_last_delimiters)}`
], options)
}
if(options.ignore_last_delimiters === true && options.columns === false){
throw new CsvError('CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS', [
'The option `ignore_last_delimiters`',
'requires the activation of the `columns` option'
], options)
}
// Normalize option `info` // Normalize option `info`
if(options.info === undefined || options.info === null || options.info === false){ if(options.info === undefined || options.info === null || options.info === false){
options.info = false options.info = false
@ -4749,7 +4774,7 @@ class Parser extends Transform {
} }
// Auto discovery of record_delimiter, unix, mac and windows supported // Auto discovery of record_delimiter, unix, mac and windows supported
if(this.state.quoting === false && record_delimiter.length === 0){ if(this.state.quoting === false && record_delimiter.length === 0){
const record_delimiterCount = this.__autoDiscoverRowDelimiter(buf, pos) const record_delimiterCount = this.__autoDiscoverRecordDelimiter(buf, pos)
if(record_delimiterCount){ if(record_delimiterCount){
record_delimiter = this.options.record_delimiter record_delimiter = this.options.record_delimiter
} }
@ -4790,12 +4815,12 @@ class Parser extends Transform {
const isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr) const isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr)
const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos+quote.length, nextChr) const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos+quote.length, nextChr)
const isNextChrDelimiter = this.__isDelimiter(buf, pos+quote.length, nextChr) const isNextChrDelimiter = this.__isDelimiter(buf, pos+quote.length, nextChr)
const isNextChrRowDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRowDelimiter(buf, pos+quote.length) : this.__isRecordDelimiter(nextChr, buf, pos+quote.length) const isNextChrRecordDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRecordDelimiter(buf, pos+quote.length) : this.__isRecordDelimiter(nextChr, buf, pos+quote.length)
// Escape a quote // Escape a quote
// Treat next char as a regular character // Treat next char as a regular character
if(escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)){ if(escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)){
pos += escape.length - 1 pos += escape.length - 1
}else if(!nextChr || isNextChrDelimiter || isNextChrRowDelimiter || isNextChrComment || isNextChrTrimable){ }else if(!nextChr || isNextChrDelimiter || isNextChrRecordDelimiter || isNextChrComment || isNextChrTrimable){
this.state.quoting = false this.state.quoting = false
this.state.wasQuoting = true this.state.wasQuoting = true
pos += quote.length - 1 pos += quote.length - 1
@ -4806,7 +4831,7 @@ class Parser extends Transform {
'Invalid Closing Quote:', 'Invalid Closing Quote:',
`got "${String.fromCharCode(nextChr)}"`, `got "${String.fromCharCode(nextChr)}"`,
`at line ${this.info.lines}`, `at line ${this.info.lines}`,
'instead of delimiter, row delimiter, trimable character', 'instead of delimiter, record delimiter, trimable character',
'(if activated) or comment', '(if activated) or comment',
], this.options, this.__context()) ], this.options, this.__context())
) )
@ -4847,25 +4872,24 @@ class Parser extends Transform {
this.info.comment_lines++ this.info.comment_lines++
// Skip full comment line // Skip full comment line
}else{ }else{
// Activate records emition if above from_line
if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0) >= from_line){
this.state.enabled = true
this.__resetField()
this.__resetRecord()
pos += recordDelimiterLength - 1
continue
}
// Skip if line is empty and skip_empty_lines activated // Skip if line is empty and skip_empty_lines activated
if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){ if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){
this.info.empty_lines++ this.info.empty_lines++
pos += recordDelimiterLength - 1 pos += recordDelimiterLength - 1
continue continue
} }
// Activate records emition if above from_line
if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0 ) >= from_line){
this.state.enabled = true
this.__resetField()
this.__resetRow()
pos += recordDelimiterLength - 1
continue
}else{
const errField = this.__onField() const errField = this.__onField()
if(errField !== undefined) return errField if(errField !== undefined) return errField
const errRecord = this.__onRow() const errRecord = this.__onRecord()
if(errRecord !== undefined) return errRecord if(errRecord !== undefined) return errRecord
}
if(to !== -1 && this.info.records >= to){ if(to !== -1 && this.info.records >= to){
this.state.stop = true this.state.stop = true
this.push(null) this.push(null)
@ -4938,7 +4962,7 @@ class Parser extends Transform {
if(this.state.wasQuoting === true || this.state.record.length !== 0 || this.state.field.length !== 0){ if(this.state.wasQuoting === true || this.state.record.length !== 0 || this.state.field.length !== 0){
const errField = this.__onField() const errField = this.__onField()
if(errField !== undefined) return errField if(errField !== undefined) return errField
const errRecord = this.__onRow() const errRecord = this.__onRecord()
if(errRecord !== undefined) return errRecord if(errRecord !== undefined) return errRecord
}else if(this.state.wasRowDelimiter === true){ }else if(this.state.wasRowDelimiter === true){
this.info.empty_lines++ this.info.empty_lines++
@ -4954,21 +4978,17 @@ class Parser extends Transform {
this.state.wasRowDelimiter = false this.state.wasRowDelimiter = false
} }
} }
// Helper to test if a character is a space or a line delimiter __onRecord(){
__isCharTrimable(chr){
return chr === space || chr === tab || chr === cr || chr === nl || chr === np
}
__onRow(){
const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options
const {enabled, record} = this.state const {enabled, record} = this.state
if(enabled === false){ if(enabled === false){
return this.__resetRow() return this.__resetRecord()
} }
// Convert the first line into column names // Convert the first line into column names
const recordLength = record.length const recordLength = record.length
if(columns === true){ if(columns === true){
if(isRecordEmpty(record)){ if(isRecordEmpty(record)){
this.__resetRow() this.__resetRecord()
return return
} }
return this.__firstLineToColumns(record) return this.__firstLineToColumns(record)
@ -5010,12 +5030,12 @@ class Parser extends Transform {
} }
if(skip_lines_with_empty_values === true){ if(skip_lines_with_empty_values === true){
if(isRecordEmpty(record)){ if(isRecordEmpty(record)){
this.__resetRow() this.__resetRecord()
return return
} }
} }
if(this.state.recordHasError === true){ if(this.state.recordHasError === true){
this.__resetRow() this.__resetRecord()
this.state.recordHasError = false this.state.recordHasError = false
return return
} }
@ -5089,7 +5109,7 @@ class Parser extends Transform {
} }
} }
} }
this.__resetRow() this.__resetRecord()
} }
__firstLineToColumns(record){ __firstLineToColumns(record){
const {firstLineToHeaders} = this.state const {firstLineToHeaders} = this.state
@ -5109,13 +5129,13 @@ class Parser extends Transform {
const normalizedHeaders = normalizeColumnsArray(headers) const normalizedHeaders = normalizeColumnsArray(headers)
this.state.expectedRecordLength = normalizedHeaders.length this.state.expectedRecordLength = normalizedHeaders.length
this.options.columns = normalizedHeaders this.options.columns = normalizedHeaders
this.__resetRow() this.__resetRecord()
return return
}catch(err){ }catch(err){
return err return err
} }
} }
__resetRow(){ __resetRecord(){
if(this.options.raw === true){ if(this.options.raw === true){
this.state.rawBuffer.reset() this.state.rawBuffer.reset()
} }
@ -5188,6 +5208,10 @@ class Parser extends Transform {
} }
return [undefined, field] return [undefined, field]
} }
// Helper to test if a character is a space or a line delimiter
__isCharTrimable(chr){
return chr === space || chr === tab || chr === cr || chr === nl || chr === np
}
// Keep it in case we implement the `cast_int` option // Keep it in case we implement the `cast_int` option
// __isInt(value){ // __isInt(value){
// // return Number.isInteger(parseInt(value)) // // return Number.isInteger(parseInt(value))
@ -5214,14 +5238,19 @@ class Parser extends Transform {
needMoreDataSize, needMoreDataSize,
// Skip if the remaining buffer smaller than record delimiter // Skip if the remaining buffer smaller than record delimiter
recordDelimiterMaxLength, recordDelimiterMaxLength,
// Skip if the remaining buffer can be row delimiter following the closing quote // Skip if the remaining buffer can be record delimiter following the closing quote
// 1 is for quote.length // 1 is for quote.length
quoting ? (quote.length + recordDelimiterMaxLength) : 0, quoting ? (quote.length + recordDelimiterMaxLength) : 0,
) )
return numOfCharLeft < requiredLength return numOfCharLeft < requiredLength
} }
__isDelimiter(buf, pos, chr){ __isDelimiter(buf, pos, chr){
const {delimiter} = this.options const {delimiter, ignore_last_delimiters} = this.options
if(ignore_last_delimiters === true && this.state.record.length === this.options.columns.length - 1){
return 0
}else if(ignore_last_delimiters !== false && typeof ignore_last_delimiters === 'number' && this.state.record.length === ignore_last_delimiters - 1){
return 0
}
loop1: for(let i = 0; i < delimiter.length; i++){ loop1: for(let i = 0; i < delimiter.length; i++){
const del = delimiter[i] const del = delimiter[i]
if(del[0] === chr){ if(del[0] === chr){
@ -5276,7 +5305,7 @@ class Parser extends Transform {
} }
return true return true
} }
__autoDiscoverRowDelimiter(buf, pos){ __autoDiscoverRecordDelimiter(buf, pos){
const {encoding} = this.options const {encoding} = this.options
const chr = buf[pos] const chr = buf[pos]
if(chr === cr){ if(chr === cr){

View File

@ -25,7 +25,7 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/github": "^4.0.0", "@actions/github": "^4.0.0",
"csv-parse": "^4.14.2", "csv-parse": "^4.15.1",
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"moment": "^2.29.1", "moment": "^2.29.1",
"semver": "^7.3.4" "semver": "^7.3.4"

View File

@ -1176,10 +1176,10 @@ cssstyle@^2.2.0:
dependencies: dependencies:
cssom "~0.3.6" cssom "~0.3.6"
csv-parse@^4.14.2: csv-parse@^4.15.1:
version "4.14.2" version "4.15.1"
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.14.2.tgz#c1329cff95a99b8773a92c4e62f8bff114b34726" resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.1.tgz#fc5a0a1b24eaa6d4c24892daa387c46f7f92f8d2"
integrity sha512-YE2xlTKtM035/94llhgsp9qFQxGi47EkQJ1pZ+mLT/98GpIsbjkMGAb7Rmu9hNxVfYFOLf10hP+rPVqnoccLgw== integrity sha512-TXIvRtNp0fqMJbk3yPR35bQIDzMH4khDwduElzE7Fl1wgnl25mnWYLSLqd/wS5GsDoX1rWtysivEYMNsz5jKwQ==
dashdash@^1.12.0: dashdash@^1.12.0:
version "1.14.1" version "1.14.1"