diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 40edd20..c81e658 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "src/read-lines.js", "type": "module", "scripts": { - "test": "./node_modules/.bin/mocha --timeout 30000", + "test": "mocha --timeout 30000", "testd": "UCI_ENV=dev ./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha --timeout 30000' || exit 0", "testdd": "UCI_LOG_LEVEL='trace' npm run testd", "testde": "UCI_LOG_LEVEL='warn' npm run testd", @@ -29,14 +29,13 @@ }, "homepage": "https://github.com/uCOMmandIt/uci-utils#readme", "dependencies": { - "@uci-utils/logger": "^0.1.0", - "p-settle": "^4.1.1" + "p-settle": "^5.1.1" }, "devDependencies": { - "chai": "^4.3.4", + "chai": "^5.1.2", "chai-arrays": "^2.2.0", - "dirname-filename-esm": "^1.0.2", - "mocha": "^8.3.2", - "nodemon": "^2.0.7" + "dirname-filename-esm": "^1.1.2", + "mocha": "^11.0.1", + "nodemon": "^3.1.9" } } diff --git a/src/read-lines.js b/src/read-lines.js index c7e005f..51c3127 100644 --- a/src/read-lines.js +++ b/src/read-lines.js @@ -4,12 +4,12 @@ import { readFile, writeFile } from 'fs' const read = promisify(readFile) const write = promisify(writeFile) import settle from 'p-settle' -import logger from '@uci-utils/logger' -let log = logger({ package:'@uci-utils/read-lines', file:'src/read-lines.js'}) +// import logger from '@uci-utils/logger' +// let log = logger({ package:'@uci-utils/read-lines', file:'src/read-lines.js'}) // read lines from one or more files function readLines (files=[],dir) { - log.debug({files:files,dir:dir,msg:'additional files'}) + // log.debug({files:files,dir:dir,msg:'additional files'}) let list = [] if (!Array.isArray(files)) files=[files] // each set in an the array is new line delimited set of ignore patterns @@ -17,13 +17,15 @@ function readLines (files=[],dir) { return settle(files.map(file => { // console.log('directory',path.dirname(file)) if (path.dirname(file)==='.') file = dir+'/'+file - log.debug({function:'readLines',file:file,msg:'reading a file of lines into array'}) + // log.debug({function:'readLines',file:file,msg:'reading a file of lines into array'}) return read(file) })) .then((sets) => { sets.forEach( set => { if (set.isFulfilled) list.push(...set.value.toString().match(/.+/g)) - else log.warn({function:'readLines', error:set.reason, msg:' was unable to read file'}) + else + console.log("unable to read file") + // log.warn({function:'readLines', error:set.reason, msg:' was unable to read file'}) }) return Promise.resolve(list) }) @@ -38,10 +40,10 @@ function writeLines (filePath,list) { return write(filePath,list.join('\n')) .then(() => { - log.info({function:'writeLines', file:filePath, msg:'wrote array to file of lines'}) + // log.info({function:'writeLines', file:filePath, msg:'wrote array to file of lines'}) }) .catch( err => { - log.fatal({function:'writeLines', error:err, msg:'unable to write array to file of lines'}) + // log.fatal({function:'writeLines', error:err, msg:'unable to write array to file of lines'}) }) } diff --git a/test/read-lines.test.js b/test/read-lines.test.js index 4e34ad7..a70bdc8 100644 --- a/test/read-lines.test.js +++ b/test/read-lines.test.js @@ -1,14 +1,13 @@ // let ignoreFiles = ['.npmignore','.gitignore'] import { readLines, writeLines } from '../src/read-lines.js' -import chai from 'chai' -import assertArrays from 'chai-arrays' import { it } from 'mocha' import { dirname } from 'dirname-filename-esm'; const __dirname = dirname(import.meta); -chai.use(assertArrays) -const expect = chai.expect +import { expect, use as chaiuse } from 'chai'; +import assertArrays from 'chai-arrays' +chaiuse(assertArrays) describe ( 'Read a File of Lines to Array and vice versa',