Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Commit

Permalink
feat: add gen-script default target directory to search
Browse files Browse the repository at this point in the history
  • Loading branch information
JhChoy committed Mar 3, 2019
1 parent c50ae4d commit c88bfa5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
8 changes: 5 additions & 3 deletions packages/vvisp/commands/README-ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,20 @@ nonUpgradeable contract의 경우 해당 속성이 없습니다.

## gen-script

> vvisp gen-script <_files..._> [options]
> vvisp gen-script [_filesOrDirectory..._] [options]
`gen-script`는 배포된 스마트 컨트랙트를 쉽게 호출 할 수 있는 자바 스크립트 라이브러리를 자동으로 생성하는 명령입니다. 튜토리얼에 사용 된 저장소는 [다음](https://github.com/HAECHI-LABS/vvisp-sample)과 같습니다.
`gen-script`는 배포된 스마트 컨트랙트를 쉽게 호출 할 수 있는 자바 스크립트 라이브러리를 자동으로 생성하는 명령입니다.
튜토리얼에 사용 된 저장소는 [다음](https://github.com/HAECHI-LABS/vvisp-sample)과 같습니다.

#### Usage

`vvisp gen-script <contract-files...> [options]`
`vvisp gen-script [filesOrDirectory...] [options]`

#### options

`-f, --front <name>`: front-end(브라우저)에서 실행 가능한 자바스크립트 소스코드로 생성합니다.

만약 입력한 파일명이 없다면 이 명령어는 자동적으로 `contracts/` 폴더 안의 모든 솔리디티 파일을 대상으로한 스크립트를 생성합니다.


#### Example
Expand Down
10 changes: 7 additions & 3 deletions packages/vvisp/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,17 @@ For nonUpgradeable contract, there is no such property.

## gen-script

> vvisp gen-script <_files..._> [options]
> vvisp gen-script [_filesOrDirectory..._] [options]
The `gen-script` is a command that automatically creates a javascript library to help you easily call deployed smart contracts. The repository used in the tutorial is as follows.(https://github.com/HAECHI-LABS/vvisp-sample)
The `gen-script` is a command that automatically creates a javascript library to help you easily call deployed smart contracts.
The repository used in the tutorial is as follows.
(https://github.com/HAECHI-LABS/vvisp-sample)

If there is no filename entered, this command will automatically generate scripts for all the solidity files in the `contracts/` folder.

#### Usage

`vvisp gen-script <contract-files...> [options]`
`vvisp gen-script [filesOrDirectory...] [options]`

#### options

Expand Down
4 changes: 2 additions & 2 deletions packages/vvisp/commands/gen-script.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { genScript } = require('../scripts');

const name = 'gen-script';
const signature = `${name} <files...>`;
const signature = `${name} [files...]`;
const description = `generate javascript libraries communicating the smart contracts`;

const register = commander =>
commander
.command(signature, { noHelp: true })
.usage('<files...> [options]')
.usage('[files...] [options]')
.option('-f, --front <name>', 'generate the front-end javascript library')
.description(description)
.action(genScript)
Expand Down
6 changes: 5 additions & 1 deletion packages/vvisp/scripts/gen-script/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = async function(files, options) {
module.exports = async function(files = [], options) {
const path = require('path');
const _ = require('lodash');
const fs = require('fs-extra');
Expand All @@ -16,6 +16,10 @@ module.exports = async function(files, options) {
frontIndex: path.join(__dirname, '../../template/frontIndex.mustache')
};

if (files.length === 0) {
files.push(path.join('./', 'contracts'));
}

for (let i = 0; i < files.length; i++) {
const file = files[i];
if (fs.statSync(file).isDirectory()) {
Expand Down

0 comments on commit c88bfa5

Please sign in to comment.