Skip to content

Commit

Permalink
fix(mod): export writeAll and other types
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Nov 9, 2023
1 parent 7a2e4bd commit 19ff379
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ provided.
```ts
import {
DependencyUpdate,
FileUpdate,
writeAll,
} from "https://deno.land/x/molt@{VERSION}/mod.ts";

const updates = await DependencyUpdate.collect("./mod.ts", {
importMap: "./deno.json",
});

const results = FileUpdate.collect(updates);
await FileUpdate.write(results);
await writeAll(results, {
onWrite: (file) => console.log(`💾 ${file.specifier}`),
});
```

##### Update all dependencies in a module and commit the changes to local git repository
Expand Down
6 changes: 3 additions & 3 deletions lib/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import { URI } from "./uri.ts";
* @example
* ```ts
* await writeAll(updates, {
* onWrite: (update) => {
* console.log(`Updated ${update.specifier}`);
* onWrite: (file) => {
* console.log(`Updated ${file.specifier}`);
* },
* });
* ```
*/
export function writeAll(
updates: DependencyUpdate[],
options?: {
onWrite?: (result: FileUpdate) => void | Promise<void>;
onWrite?: (file: FileUpdate) => void | Promise<void>;
},
) {
return FileUpdate.write(FileUpdate.collect(updates), options);
Expand Down
12 changes: 8 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@
* ```ts
* import {
* DependencyUpdate,
* FileUpdate,
* writeAll,
* } from "https://deno.land/x/molt@{VERSION}/mod.ts";
*
* const updates = await DependencyUpdate.collect("./mod.ts", {
* importMap: "./deno.json",
* });
*
* const results = FileUpdate.collect(updates);
* await FileUpdate.write(results);
* await writeAll(updates);
* ```
*
* @module
*/

export { DependencyUpdate } from "./lib/update.ts";
export { FileUpdate } from "./lib/file.ts";
export { FileUpdate, writeAll } from "./lib/file.ts";
export type { Dependency, LatestDependency } from "./lib/dependency.ts";
export type { SemVerString } from "./lib/semver.ts";
export type { ImportMap } from "./lib/import_map.ts";
export type { URI } from "./lib/uri.ts";
export type { Path } from "./lib/types.ts";

0 comments on commit 19ff379

Please sign in to comment.