From fb7dab23d418fed6a6c9b8e9668dc87cb219ba61 Mon Sep 17 00:00:00 2001 From: Barrie Treloar Date: Wed, 27 Jun 2018 12:17:08 +0930 Subject: [PATCH] Allow directories again. ISSUE #451 --- .../src/commands/import/Importer.ts | 13 ++++++++++--- .../graphcool-cli-core/src/commands/import/index.ts | 4 ---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cli/packages/graphcool-cli-core/src/commands/import/Importer.ts b/cli/packages/graphcool-cli-core/src/commands/import/Importer.ts index 9b519006c..423acf805 100644 --- a/cli/packages/graphcool-cli-core/src/commands/import/Importer.ts +++ b/cli/packages/graphcool-cli-core/src/commands/import/Importer.ts @@ -43,8 +43,13 @@ export class Importer { throw new Error(`Import path ${importPath} does not exist`) } this.config = config - this.importPath = importPath - this.importDir = path.join(config.cwd, '.import/') + if (importPath.endsWith('.zip')) { + this.importPath = importPath + this.importDir = path.resolve(config.cwd, '.import/') + } + else { + this.importDir = path.resolve(config.cwd, importPath) + } this.client = client this.types = types this.out = out @@ -88,7 +93,9 @@ export class Importer { }) } async upload(projectId: string) { - await this.unzip() + if (this.importPath) { + await this.unzip() + } let before = Date.now() this.out.action.start('Validating data') const files = await this.getFiles() diff --git a/cli/packages/graphcool-cli-core/src/commands/import/index.ts b/cli/packages/graphcool-cli-core/src/commands/import/index.ts index f3af526cb..39059996b 100644 --- a/cli/packages/graphcool-cli-core/src/commands/import/index.ts +++ b/cli/packages/graphcool-cli-core/src/commands/import/index.ts @@ -22,10 +22,6 @@ export default class Import extends Command { const { id } = await this.env.getTarget(target) - if (!source.endsWith('.zip')) { - throw new Error(`Source must end with .zip`) - } - if (!fs.pathExistsSync(source)) { throw new Error(`Path ${source} does not exist`) }