Skip to content

Commit

Permalink
fix: path undefined when workspace is empty (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
luhc228 authored Jul 7, 2020
1 parent c2d5f26 commit bc748d2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion extensions/iceworks-component-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@
"url": "https://github.com/ice-lab/iceworks/issues",
"email": "iceworksteam@163.com"
}
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-page-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@
"url": "https://github.com/ice-lab/iceworks/issues",
"email": "iceworksteam@163.com"
}
}
}
4 changes: 2 additions & 2 deletions packages/block-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iceworks/block-service",
"version": "0.1.8",
"version": "0.1.9",
"description": "Iceworks block service for VSCode extension.",
"files": [
"lib"
Expand Down Expand Up @@ -29,4 +29,4 @@
"access": "public"
},
"gitHead": "fc5b35f95ab4cc24898845916acf598c2f34d576"
}
}
10 changes: 2 additions & 8 deletions packages/block-service/src/utils/downloadBlock.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import * as path from 'path';
import * as fsExtra from 'fs-extra';
import * as vscode from 'vscode';
import { getAndExtractTarball } from 'ice-npm-utils';
import { IMaterialBlock, getTarballURLByMaterielSource } from '@iceworks/material-utils';
import { getIceVersion, packageJSONFilename, getPackageJSON } from '@iceworks/project-service';

const { workspace } = vscode;

const projectPath = workspace.rootPath!;
const packagePath = path.join(projectPath, packageJSONFilename);
import { getIceVersion, getPackageJSON, packageJSONPath } from '@iceworks/project-service';

export async function downloadBlock(block: IMaterialBlock, targetDir: string, log: (text: string) => void): Promise<string> {
const { name: blockName, source, repository } = block;
const projectPackageJSON = await getPackageJSON(packagePath);
const projectPackageJSON = await getPackageJSON(packageJSONPath);
await fsExtra.mkdirp(targetDir);

const iceVersion: string = getIceVersion(projectPackageJSON);
Expand Down
2 changes: 1 addition & 1 deletion packages/project-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iceworks/project-service",
"version": "0.1.9",
"version": "0.1.10",
"description": "Iceworks project service for VSCode extension.",
"files": [
"lib"
Expand Down
1 change: 1 addition & 0 deletions packages/project-service/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const COMPONENT_DIR_NAME = 'components';
export const dependencyDir = 'node_modules';
export const packageJSONFilename = 'package.json';
export const jsxFileExtnames = ['.jsx', '.tsx', '.js'];
export const packageJSONPath = path.join(projectPath, packageJSONFilename);

export const generatorCreatetaskUrl = 'https://api.def.alibaba-inc.com/api/generator/generator/createtask';
export const generatorTaskResultUrl = 'https://api.def.alibaba-inc.com/api/generator/generator/task';
Expand Down

0 comments on commit bc748d2

Please sign in to comment.