Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
appcypher committed Sep 28, 2022
1 parent 0228c17 commit e598c79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 104 deletions.
98 changes: 0 additions & 98 deletions crates/wasm/examples/graph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ console.log(`root id after "mkdir -p /pictures/cats": ${rootDir.getId()}`);

var tree = await draw(rootDir, store);

// ------------------------------------------------------------------------------
// mkdir -p /pictures/dogs
// ------------------------------------------------------------------------------

var { rootDir } = await rootDir.mkdir(["pictures", "dogs"], time, store);

console.log(`root id after "mkdir -p /pictures/dogs": ${rootDir.getId()}`);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// mkdir -p /videos/dogs
//------------------------------------------------------------------------------
Expand All @@ -50,91 +40,3 @@ var { rootDir } = await rootDir.mkdir(["videos", "dogs"], time, store);
console.log(`root id after "mkdir -p /videos/dogs": ${rootDir.getId()}`);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// echo '...' >> /videos/dogs/puppy.mp4
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.write(
["videos", "dogs", "puppy.mp4"],
sampleCID,
time,
store
);

console.log(
`root id after "echo '...' >> /videos/dogs/puppy.mp4": ${rootDir.getId()}`
);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// echo '...' >> /pictures/cats/kitten.png
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.write(
["pictures", "cats", "kitten.png"],
sampleCID,
time,
store
);

console.log(
`root id after "echo '...' >> /pictures/cats/kitten.png": ${rootDir.getId()}`
);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// mkdir -p /music/rock
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.mkdir(["music", "rock"], time, store);

console.log(`root id after "mkdir -p /music/rock": ${rootDir.getId()}`);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// echo '...' >> /music/rock/toxicity.mp3
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.write(
["music", "rock", "toxicity.mp3"],
sampleCID,
time,
store
);

console.log(
`root id after "echo '...' >> /music/rock/toxicity.mp3": ${rootDir.getId()}`
);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// rm /pictures/cats/kitten.png
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.rm(["pictures", "cats", "kitten.png"], store);

console.log(`root id after "rm /pictures/cats/kitten.png": ${rootDir.getId()}`);

var tree = await draw(rootDir, store, tree);

//------------------------------------------------------------------------------
// echo '...' >> /movies/anime/ghibli/ponyo.mov
//------------------------------------------------------------------------------

var { rootDir } = await rootDir.write(
["movies", "anime", "ghibli", "ponyo.mov"],
sampleCID,
time,
store
);

console.log(
`root id after "echo '...' >> /movies/anime/ghibli/ponyo.mov": ${rootDir.getId()}`
);

var tree = await draw(rootDir, store, tree);
7 changes: 5 additions & 2 deletions crates/wasm/examples/graph/src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ export class Tree {
async getChildrenForVertex(vertex: Vertex): Promise<Vertex[]> {
if (vertex.node && vertex.node.isDir()) {
const dir = vertex.node.asDir();
const { result }: { result: string[] } = await dir.ls([], this.store);
const { result }: { result: { name: string }[] } = await dir.ls(
[],
this.store
);

if (result.length > 0) {
const children: Vertex[] = [];
for (let name of result) {
for (let { name } of result) {
const node: PublicNode = await dir.lookupNode(name, this.store);
children.push(new Vertex(name, node, vertex, this, vertex.rootDir));
}
Expand Down
4 changes: 0 additions & 4 deletions crates/wasm/examples/graph/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");

Expand Down Expand Up @@ -29,9 +28,6 @@ module.exports = {
],
},
plugins: [
new HtmlWebpackPlugin({
template: "index.html",
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "../.."),
}),
Expand Down

0 comments on commit e598c79

Please sign in to comment.