diff --git a/.github/workflows/test-main.yml b/.github/workflows/test-main.yml index e07463cd21ac05c1b27c55befce91b4b7aec4534..e57fdc59a0d087db7ecca08d62193d9c9d55d9e9 100644 --- a/.github/workflows/test-main.yml +++ b/.github/workflows/test-main.yml @@ -7,7 +7,12 @@ on: jobs: test-main: - runs-on: ubuntu-latest + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest'] + + runs-on: ${{ matrix.os }} + steps: - name: Checkout uses: actions/checkout@v3 diff --git a/core/base-service/loader.js b/core/base-service/loader.js index cf499eca1560f5e68220203c0dde252756317d27..9bbf0c948d42c22294e1b529a9453c8e2bc82312 100644 --- a/core/base-service/loader.js +++ b/core/base-service/loader.js @@ -13,6 +13,13 @@ const serviceDir = path.join( 'services' ) +function toUnixPath(path) { + // glob does not allow \ as a path separator + // see https://github.com/isaacs/node-glob/blob/main/changelog.md#80 + // so we need to convert to use / for use with glob + return path.replace(/\\/g, '/') +} + class InvalidService extends Error { constructor(message) { super(message) @@ -22,7 +29,9 @@ class InvalidService extends Error { async function loadServiceClasses(servicePaths) { if (!servicePaths) { - servicePaths = glob.sync(path.join(serviceDir, '**', '*.service.js')) + servicePaths = glob.sync( + toUnixPath(path.join(serviceDir, '**', '*.service.js')) + ) } const serviceClasses = [] @@ -42,8 +51,8 @@ async function loadServiceClasses(servicePaths) { if (serviceClass && serviceClass.prototype instanceof BaseService) { // Decorate each service class with the directory that contains it. serviceClass.serviceFamily = servicePath - .replace(serviceDir, '') - .split(path.sep)[1] + .replace(toUnixPath(serviceDir), '') + .split('/')[1] serviceClass.validateDefinition() return serviceClasses.push(serviceClass) } diff --git a/lib/logos.spec.js b/lib/logos.spec.js index 0d6eaae40067c90509af466c4f1d760f1865c0e2..cc2e415c72ccccb5062ee2a4bee20d07dca5847b 100644 --- a/lib/logos.spec.js +++ b/lib/logos.spec.js @@ -33,7 +33,7 @@ describe('Logo helpers', function () { test(prepareNamedLogo, () => { // NPM uses multiple colors so the color param should be ignored const npmLogo = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZD0iTTAgMGg0MHY0MEgwVjB6IiBmaWxsPSIjY2IwMDAwIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTcgN2gyNnYyNmgtN1YxNGgtNnYxOUg3eiIvPjwvc3ZnPgo=' + 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZD0iTTAgMGg0MHY0MEgwVjB6IiBmaWxsPSIjY2IwMDAwIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTcgN2gyNnYyNmgtN1YxNGgtNnYxOUg3eiIvPjwvc3ZnPg==' given({ name: 'npm' }).expect(npmLogo) given({ name: 'npm', color: 'blue' }).expect(npmLogo) @@ -115,7 +115,7 @@ describe('Logo helpers', function () { undefined ) given('npm', {}).expect( - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZD0iTTAgMGg0MHY0MEgwVjB6IiBmaWxsPSIjY2IwMDAwIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTcgN2gyNnYyNmgtN1YxNGgtNnYxOUg3eiIvPjwvc3ZnPgo=' + 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZD0iTTAgMGg0MHY0MEgwVjB6IiBmaWxsPSIjY2IwMDAwIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTcgN2gyNnYyNmgtN1YxNGgtNnYxOUg3eiIvPjwvc3ZnPg==' ) }) }) diff --git a/lib/svg-helpers.js b/lib/svg-helpers.js index 040df8a503f8e48ee14c3bddbb55bf4a81db0316..c688c347766fce0529234dc9370f2d19f738f980 100644 --- a/lib/svg-helpers.js +++ b/lib/svg-helpers.js @@ -1,5 +1,7 @@ function svg2base64(svg) { - return `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}` + return `data:image/svg+xml;base64,${Buffer.from(svg.trim()).toString( + 'base64' + )}` } export { svg2base64 }