Skip to content

Commit

Permalink
Merge pull request #6 from nearprotocol/j-clean
Browse files Browse the repository at this point in the history
[clean command] - add clean command
  • Loading branch information
janedegtiareva committed Mar 15, 2019
2 parents 1bf91a0 + a6a9c4b commit ff510c4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
16 changes: 13 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const neardev = require('nearlib/dev');
const UnencryptedFileSystemKeyStore = require('./unencrypted_file_system_keystore');
const fs = require('fs');
const yargs = require('yargs');
var ncp = require('ncp').ncp;
const ncp = require('ncp').ncp;
const rimraf = require('rimraf');

ncp.limit = 16;

Expand Down Expand Up @@ -56,7 +57,17 @@ gulp.task('copyfiles', async function(done) {
done();
});

gulp.task('build', gulp.series('copyfiles', 'build:all'));
gulp.task('clean', async function(done) {
const rmDirFn = () => {
return new Promise(resolve => {
rimraf(yargs.argv.out_dir, response => resolve(response));
})};
await rmDirFn();
console.log("clean done");
done();
});

gulp.task('build', gulp.series('clean', 'copyfiles', 'build:all'));

// Only works for dev environments
gulp.task('createDevAccount', async function(argv) {
Expand All @@ -80,7 +91,6 @@ gulp.task('createDevAccount', async function(argv) {
keyStore.setKey(accountId, keyPair);
});


async function deployContractAndWaitForTransaction(accountId, contractName, data, near) {
const deployContractResult = await near.deployContract(contractName, data);
const waitResult = await near.waitForTransactionResult(deployContractResult);
Expand Down
24 changes: 24 additions & 0 deletions near
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,34 @@ const createAccount = {
}
};

const clean = {
command: 'clean',
desc: 'clean the build environment',
builder: (yargs) => yargs
.option('out_dir', {
desc: 'build directory',
type: 'string',
default: './out'
})
,
handler: (argv) => {
gulp.on('error', function(e) {
console.log("Clean failed. Error:")
console.log(e.error);
});
if (gulp.task('clean')) {
const result = gulp.task('clean')(argv).catch(console.log);
} else {
throw "Unexpected error: clean task not found in gulpfile."
}
}
};

yargs // eslint-disable-line
.command(createAccount)
.command(build)
.command(deploy)
.command(clean)
.demandCommand(1, 'Please enter a command')
.argv;

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-shell",
"version": "0.0.7",
"version": "0.0.8",
"description": "Command line utilities to interact with near blockchain",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ff510c4

Please sign in to comment.