11import { parseArgs } from "@std/cli/parse-args" ;
22import { createHttpError } from "@std/http/http-errors" ;
3- import { join } from "@std/path" ;
3+ import { dirname , join , relative } from "@std/path" ;
44
55// Regex for https://deno.land/x/deno_slack_api@x .x.x/
66const API_REGEX =
@@ -15,15 +15,22 @@ async function main() {
1515 } ,
1616 } ) ;
1717
18- const importFileJsonIn = await Deno . readTextFile ( flags [ "import-file" ] ) ;
18+ const importFilePath = await Deno . realPath ( flags [ "import-file" ] ) ;
19+ const importFileDir = dirname ( importFilePath ) ;
20+ const apiDir = await Deno . realPath ( flags . api ) ;
21+
22+ const importFileJsonIn = await Deno . readTextFile ( importFilePath ) ;
1923 console . log ( "`import_map.json` in content:" , importFileJsonIn ) ;
2024
2125 const importFile = JSON . parse ( importFileJsonIn ) ;
2226 const denoSlackSdkValue = importFile [ "imports" ] [ "deno-slack-sdk/" ] ;
2327
2428 const apiDepsInSdk = await apiDepsIn ( denoSlackSdkValue ) ;
2529
26- const apiPackageSpecifier = join ( flags . api , "/src/" ) ;
30+ const apiPackageSpecifier = join (
31+ relative ( importFileDir , apiDir ) ,
32+ "/src/" ,
33+ ) ;
2734
2835 importFile [ "imports" ] [ "deno-slack-api/" ] = apiPackageSpecifier ;
2936 importFile [ "scopes" ] = {
@@ -39,7 +46,7 @@ async function main() {
3946 } ;
4047
4148 const parentFileJsonIn = await Deno . readTextFile (
42- join ( flags . api , "/deno.jsonc" ) ,
49+ join ( apiDir , "/deno.jsonc" ) ,
4350 ) ;
4451 console . log ( "parent `import file` in content:" , parentFileJsonIn ) ;
4552 const parentImportFile = JSON . parse ( parentFileJsonIn ) ;
0 commit comments