Skip to content

Commit

Permalink
Resolve near library mappings in readFile
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Apr 11, 2019
1 parent 7defb86 commit cede2af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 13 additions & 0 deletions gulp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ function getAsc() {
} else if (path.startsWith(baseDir) && path.indexOf(".near.ts") != -1) {
path = path.replace(new RegExp("^" + baseDir), "out");
}

if (!fs.existsSync(path)) {
// TODO: Try node_modules instead of fixed hardcode
const mapping = {
"assembly/near.ts" : "./node_modules/near-runtime-ts/near.ts",
"assembly/json/encoder.ts" : "./node_modules/assemblyscript-json/assembly/encoder.ts",
"assembly/json/decoder.ts" : "./node_modules/assemblyscript-json/assembly/decoder.ts",
}
if (path in mapping) {
path = mapping[path]
}
}

return fs.readFileSync(path).toString("utf8");
},
writeFile: (filename, contents) => {
Expand Down
5 changes: 0 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ gulp.task('newProject', async function() {
ncp (source_dir, yargs.argv.project_dir, response => resolve(response));
})};
await copyDirFn();
let assemblyDir = proj_dir + "/assembly";
await copyFileFn("./node_modules/near-runtime-ts/near.ts", assemblyDir + "/near.ts");
await ensureDir(assemblyDir + "/json");
await copyFileFn("./node_modules/assemblyscript-json/assembly/encoder.ts", assemblyDir + "/json/encoder.ts");
await copyFileFn("./node_modules/assemblyscript-json/assembly/decoder.ts", assemblyDir + "/json/decoder.ts");
console.log('Copying project files complete.')
});

Expand Down

0 comments on commit cede2af

Please sign in to comment.