From 63ecec52240222d84021df61cc4c3d61c276b064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmetcan=20=C3=96ZCAN?= Date: Fri, 28 Aug 2020 12:23:46 +0300 Subject: [PATCH] First commit --- .gitignore | 1 + bin/duke.ts | 3 +++ dukefile.ts | 23 +++++++++++++++++++++++ start.ts | 10 ++++++++++ tsconfig.json | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 .gitignore create mode 100644 bin/duke.ts create mode 100644 dukefile.ts create mode 100644 start.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f61e320 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*/ \ No newline at end of file diff --git a/bin/duke.ts b/bin/duke.ts new file mode 100644 index 0000000..19243f6 --- /dev/null +++ b/bin/duke.ts @@ -0,0 +1,3 @@ +import start from "../start.ts"; + +start(Deno.args); diff --git a/dukefile.ts b/dukefile.ts new file mode 100644 index 0000000..ce455d7 --- /dev/null +++ b/dukefile.ts @@ -0,0 +1,23 @@ +const dukefileName = "./dukefile.ts"; + +let dukefilePath = await Deno.realPath(dukefileName); + +switch (Deno.build.os) { + case "windows": + dukefilePath = dukefilePath.slice("c:".length); + break; + + default: + break; +} + +let dukefile: { [key: string]: Function }; + +try { + dukefile = await import(dukefilePath); +} catch (err) { + console.error("Can not read dukefile", err); + Deno.exit(1); +} + +export default dukefile; diff --git a/start.ts b/start.ts new file mode 100644 index 0000000..9b49aee --- /dev/null +++ b/start.ts @@ -0,0 +1,10 @@ +import dukefile from "./dukefile.ts"; + +export default function start(args: string[]) { + const taskName = args[0] || "default"; + const task = dukefile[taskName]; + const taskArgs = args.slice(1); + + // Run task + task(...taskArgs); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6272479 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,39 @@ +{ + "compilerOptions": { + "allowJs": true, + "baseUrl": ".", + "esModuleInterop": true, + "lib": [ + "esnext" + ], + "module": "amd", + "moduleResolution": "node", + "noEmit": true, + "paths": { + // Paths have to be relative to `baseUrl` + "http://*": [ + // This is the OSX location (assumine root is two levels up) + "../../Library/Caches/deno/deps/http/*", + // This is the typical location a Linux + "../../.cache/deno/deps/http/*" + ], + "https://*": [ + // This is the OSX location (assumine root is two levels up) + "../../Library/Caches/deno/deps/https/*", + // This is the typical location a Linux + "../../.cache/deno/deps/https/*" + ] + }, + "plugins": [ + { + "name": "deno_ls_plugin" + } + ], + "pretty": true, + "resolveJsonModule": true, + "target": "esnext" + }, + "include": [ + "./**/*.ts" + ] +} \ No newline at end of file