Skip to content

Commit

Permalink
Get .ts dependencies from appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
janedegtiareva committed Mar 15, 2019
1 parent a6a9c4b commit 9c6d776
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,34 @@ gulp.task("build:all", gulp.series('build:model', 'build:bindings', function (do
], done);
}));

async function ensureDir (dirPath) {
try {
await new Promise((resolve, reject) => {
fs.mkdir(dirPath, { recursive: true }, err => err ? reject(err) : resolve())
})
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
}

gulp.task('copyfiles', async function(done) {
// Need to wait for the copy to finish, otherwise next tasks do not find files.
console.log("Copying files to build directory");
const copyFileFn = () => {
console.log("Copying files to build directory v2");
const copyDirFn = () => {
return new Promise(resolve => {
ncp (yargs.argv.src_dir, yargs.argv.out_dir, response => resolve(response));
})};
await copyFileFn();
console.log("Copying files complete");
await copyDirFn();

// find the dependencies
const copyFileFn = (from, to) => {
return new Promise(resolve => {
ncp (from, to, response => resolve(response));
})};
await copyFileFn("./node_modules/near-runtime-ts/near.ts", yargs.argv.out_dir + "/near.ts");
await ensureDir(yargs.argv.out_dir + "/json");
await copyFileFn("./node_modules/assemblyscript-json/assembly/encoder.ts", yargs.argv.out_dir + "/json/encoder.ts");
await copyFileFn("./node_modules/assemblyscript-json/assembly/decoder.ts", yargs.argv.out_dir + "/json/decoder.ts");
done();
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"gulp": "^4.0.0",
"ncp": "^2.0.0",
"nearlib": "^0.3.4",
"rimraf": "^2.6.3",
"run-sequence": "^2.2.1",
"yargs": "^13.2.1"
}
Expand Down

0 comments on commit 9c6d776

Please sign in to comment.