From 2d27436129df840b7bd3227ccc0e194cfcff200a Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Thu, 20 Feb 2020 14:59:47 +0100 Subject: [PATCH] review comments --- frontend/packages/cli/package.json | 6 +++--- frontend/packages/cli/src/commands/createPlugin.test.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/packages/cli/package.json b/frontend/packages/cli/package.json index 93a224d109..9d14a392a3 100644 --- a/frontend/packages/cli/package.json +++ b/frontend/packages/cli/package.json @@ -14,6 +14,7 @@ "devDependencies": { "@spotify/web-scripts": "^6.0.0", "@types/node": "^13.7.2", + "@types/inquirer": "^6.5.0", "nodemon": "^2.0.2", "ts-node": "^8.6.2" }, @@ -21,12 +22,11 @@ "backstage-cli": "bin/backstage-cli" }, "dependencies": { - "@types/inquirer": "^6.5.0", "commander": "^4.1.1", "dashify": "^2.0.0", "handlebars": "^4.7.3", - "inquirer": "^7.0.4", - "replace-in-file": "^5.0.2" + "replace-in-file": "^5.0.2", + "inquirer": "^7.0.4" }, "files": [ "templates", diff --git a/frontend/packages/cli/src/commands/createPlugin.test.ts b/frontend/packages/cli/src/commands/createPlugin.test.ts index 6836e3270e..46d7bc982f 100644 --- a/frontend/packages/cli/src/commands/createPlugin.test.ts +++ b/frontend/packages/cli/src/commands/createPlugin.test.ts @@ -1,21 +1,23 @@ import fs from 'fs'; import path from 'path'; +import os from 'os'; import { createPluginFolder, createFileFromTemplate } from './createPlugin'; describe('createPlugin', () => { describe('createPluginFolder', () => { it('should create a plugin directory in the correct place', () => { - const tempDir = fs.mkdtempSync('createPluginTest'); + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-')); try { const pluginFolder = createPluginFolder(tempDir, 'foo'); expect(fs.existsSync(pluginFolder)).toBe(true); + expect(pluginFolder).toMatch(/packages\/plugins\/foo/); } finally { fs.rmdirSync(tempDir, { recursive: true }); } }); it('should not create a plugin directory if it already exists', () => { - const tempDir = fs.mkdtempSync('createPluginTest'); + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-')); try { const pluginFolder = createPluginFolder(tempDir, 'foo'); expect(fs.existsSync(pluginFolder)).toBe(true); @@ -30,7 +32,7 @@ describe('createPlugin', () => { describe('createFileFromTemplate', () => { it('should generate a valid output with inserted values', () => { - const tempDir = fs.mkdtempSync('createFileFromTemplate'); + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-')); try { const sourceData = '{"name": "@spotify-backstage/{{id}}"}'; const targetData = '{"name": "@spotify-backstage/foo"}';