I am attempting to make some changes to a library called ExcelJS, I want to continue to improve the project and add things like standardization from ECMA-376 and fixing some long standing issue with the project. Right now I am trying to ensure all tests pass. For some reason, the one issue that keeps me from passing mostly everything is a weird MacOS different in the order in which files are read.
Here we can see that I added some logging to the Github Action running this test to show that the value SharedStrings is undefined. On top of this, I can see that the xml file containing the SharedStrings values isnt even read. Before reading the worksheet, it should first get to a file inside the xl/
dir called xl/sharedStrings.xml
. The other values are being read fine at the same depth. There are other tests that do this and they succeed perfectly fine.
Missing Shared Strings
Here is a code snipped of where the files get read…
async *parse(input, options) {
if (options) this.options = options;
// Turn input into a stream. If string stream then we good!
const stream = (this.stream = this._getStream(input || this.input));
//parse Zip stream
const zip = unzip.Parse({forceStream: true});
stream.pipe(zip);
// worksheets, deferred for parsing after shared strings reading
const waitingWorkSheets = [];
// Something wrong here with order of operations or something.
for await (const entry of iterateStream(zip)) {
log('entryPath ', entry.path);
let match;
let sheetNo;
switch (entry.path) {
case '_rels/.rels':
break;
case 'xl/_rels/workbook.xml.rels':
await this._parseRels(entry);
break;
case 'xl/workbook.xml':
await this._parseWorkbook(entry);
break;
case 'xl/sharedStrings.xml':
yield* this._parseSharedStrings(entry);
break;
case 'xl/styles.xml':
await this._parseStyles(entry);
break;
default:
if (entry.path.match(/xl/worksheets/sheetd+[.]xml/)) {
match = entry.path.match(/xl/worksheets/sheet(d+)[.]xml/);
sheetNo = match[1];
if (this.sharedStrings && this.workbookRels) {
yield* this._parseWorksheet(iterateStream(entry), sheetNo);
} else {
// create temp file for each worksheet
await new Promise((resolve, reject) => {
tmp.file((err, path, fd, tempFileCleanupCallback) => {
if (err) {
return reject(err);
}
waitingWorkSheets.push({sheetNo, path, tempFileCleanupCallback});
const tempStream = fs.createWriteStream(path);
tempStream.on('error', reject);
entry.pipe(tempStream);
return tempStream.on('finish', () => {
return resolve();
});
});
});
}
} else if (entry.path.match(/xl/worksheets/_rels/sheetd+[.]xml.rels/)) {
match = entry.path.match(/xl/worksheets/_rels/sheet(d+)[.]xml.rels/);
sheetNo = match[1];
yield* this._parseHyperlinks(iterateStream(entry), sheetNo);
}
break;
}
entry.autodrain();
}
I have looked into the test that performs this and it looks very similar to other tests that do the same thing. All these tests run fine on the windows and linux actions but MacOS seems to have a weird quirk with directorys.
I have a feeling that although the code snippet is included, it has something to do with either file names or the library used for unzip called unzipper.
Carter Tomlenovich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.