• Stuart Neilson 1
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
I'm running on windows 10, sfdx version 6.1.19, and getting an error when I try to pull source froma scratch org.  I feel like I've tracked it down to some code in node_modules\sfdx-cli\node_modules\salesforce-alm\dist\lib\typeDefUtil.js  which seems to assume a POSIX path seperator.  The parameter auraBundleFileProperties is an array of objects representing file properties.  The fullName property doesn't seem consistent in what path separator is being used.  Sometimes it's '/', Sometimes it's '\' -- I was able to solve the issue by changing the line

            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);

to

            const parentBundle = auraBundleFileProperties.find(fileProperty => path.normalize(fileProperty.fullName).split(path.sep)[0] === bundleName);

That seemed to work, but I've obviously hacked the original code delivered by SF... Has anyone else run into this issue?

The function was originally written as...
static getDefaultAggregateMetadataPath(devName, typeDef, defaultSrcDir, metadataRegistry, auraBundleFileProperties) {
        let metadataPath;
        const defaultTypeDir = !util.isNullOrUndefined(typeDef.defaultDirectory) ?
            path.join(defaultSrcDir, typeDef.defaultDirectory) : defaultSrcDir;
        if (typeDef.metadataName === metadataRegistry.typeDefs.AuraDefinitionBundle.metadataName) {
            const bundleName = devName.split(path.sep)[0];
            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);
            const fileName = `${path.basename(parentBundle.fileName)}${metadataRegistry.metadataFileExt}`;
            metadataPath = path.join(defaultTypeDir, bundleName, fileName);
        }
       .... more code.....
}
I'm running on windows 10, sfdx version 6.1.19, and getting an error when I try to pull source froma scratch org.  I feel like I've tracked it down to some code in node_modules\sfdx-cli\node_modules\salesforce-alm\dist\lib\typeDefUtil.js  which seems to assume a POSIX path seperator.  The parameter auraBundleFileProperties is an array of objects representing file properties.  The fullName property doesn't seem consistent in what path separator is being used.  Sometimes it's '/', Sometimes it's '\' -- I was able to solve the issue by changing the line

            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);

to

            const parentBundle = auraBundleFileProperties.find(fileProperty => path.normalize(fileProperty.fullName).split(path.sep)[0] === bundleName);

That seemed to work, but I've obviously hacked the original code delivered by SF... Has anyone else run into this issue?

The function was originally written as...
static getDefaultAggregateMetadataPath(devName, typeDef, defaultSrcDir, metadataRegistry, auraBundleFileProperties) {
        let metadataPath;
        const defaultTypeDir = !util.isNullOrUndefined(typeDef.defaultDirectory) ?
            path.join(defaultSrcDir, typeDef.defaultDirectory) : defaultSrcDir;
        if (typeDef.metadataName === metadataRegistry.typeDefs.AuraDefinitionBundle.metadataName) {
            const bundleName = devName.split(path.sep)[0];
            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);
            const fileName = `${path.basename(parentBundle.fileName)}${metadataRegistry.metadataFileExt}`;
            metadataPath = path.join(defaultTypeDir, bundleName, fileName);
        }
       .... more code.....
}