Skip to content

Commit b1870c1

Browse files
committed
Only run import-map within install if its a theme repo
1 parent 27e7259 commit b1870c1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/commands/theme/component/install.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import Args from '../../../utilities/args.js'
1111
import BaseCommand from '../../../utilities/base-command.js'
1212
import Flags from '../../../utilities/flags.js'
13+
import {isThemeRepo} from '../../../utilities/validate.js'
1314
import GenerateImportMap from '../generate/import-map.js'
1415
import Clean from './clean.js'
1516
import Copy from './copy.js'
@@ -42,6 +43,9 @@ export default class Install extends BaseCommand {
4243
await Manifest.run([this.args[Args.DEST_DIR]!])
4344
await Copy.run([this.args[Args.DEST_DIR]!])
4445
await Clean.run([this.args[Args.DEST_DIR]!])
45-
await GenerateImportMap.run([this.args[Args.DEST_DIR]!, '--quiet'])
46+
47+
if (isThemeRepo(this.args[Args.DEST_DIR])) {
48+
await GenerateImportMap.run([this.args[Args.DEST_DIR]!, '--quiet'])
49+
}
4650
}
4751
}

test/commands/theme/component/install.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const fixturesPath = path.join(__dirname, '../../../fixtures')
1515
const collectionPath = path.join(__dirname, '../../../fixtures/collection')
1616
const themePath = path.join(__dirname, '../../../fixtures/theme')
1717
const testCollectionPath = path.join(fixturesPath, 'test-collection')
18+
const testCollectionBPath = path.join(fixturesPath, 'test-collection-b')
1819
const testThemePath = path.join(fixturesPath, 'test-theme')
1920

2021
describe('theme component install', () => {
@@ -32,13 +33,15 @@ describe('theme component install', () => {
3233
generateRunStub = sandbox.stub(GenerateImportMap.prototype, 'run').resolves()
3334

3435
fs.cpSync(collectionPath, testCollectionPath, { recursive: true })
36+
fs.cpSync(collectionPath, testCollectionBPath, { recursive: true })
3537
fs.cpSync(themePath, testThemePath, { recursive: true })
3638
process.chdir(testCollectionPath)
3739
})
3840

3941
afterEach(() => {
4042
sandbox.restore()
4143
fs.rmSync(testCollectionPath, { force: true, recursive: true })
44+
fs.rmSync(testCollectionBPath, { force: true, recursive: true })
4245
fs.rmSync(testThemePath, { force: true, recursive: true })
4346
})
4447

@@ -57,11 +60,16 @@ describe('theme component install', () => {
5760
expect(cleanRunStub.calledOnce).to.be.true
5861
})
5962

60-
it('runs the theme component generate import map command', async () => {
63+
it('runs the theme component generate import map command if the destination is a theme repo', async () => {
6164
await Install.run([testThemePath])
6265
expect(generateRunStub.calledOnce).to.be.true
6366
})
6467

68+
it('does not run the theme component generate import map command if the destination is not a theme repo', async () => {
69+
await Install.run([testCollectionBPath])
70+
expect(generateRunStub.calledOnce).to.be.false
71+
})
72+
6573
it('runs sub-commands in correct order', async () => {
6674
await Install.run([testThemePath])
6775
sinon.assert.callOrder(manifestRunStub, copyRunStub, cleanRunStub, generateRunStub)

0 commit comments

Comments
 (0)