Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from slackapi/bradh-absolutepaths
Browse files Browse the repository at this point in the history
handle absolute paths for source and output
  • Loading branch information
selfcontained authored Mar 7, 2022
2 parents 5161b37 + ccdbdfc commit 6a7edb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import * as path from "https://deno.land/[email protected]/path/mod.ts";
import { ensureDir } from "https://deno.land/[email protected]/fs/mod.ts"
import { Options } from './types.ts';

// deno-lint-ignore no-explicit-any
export const createFunctions = async (options: Options, manifest: any) => {
// Find all the run on slack functions
if (!options.outputDirectory) {
throw new Error('Cannot build function files if no output option is provided');
}

// Ensure functions directory exists
const functionsPath = path.join(options.outputDirectory, 'functions');
await ensureDir(functionsPath);

// Find all the run on slack functions
for (const fnId in manifest.functions) {
const fnDef = manifest.functions[fnId];

Expand Down Expand Up @@ -37,10 +45,6 @@ export const createFunctions = async (options: Options, manifest: any) => {
check: false,
});

if (!options.outputDirectory) {
throw new Error('Cannot build function files if no output option is provided');
}

// Write FN File and sourcemap file
const fnFileRelative = path.join('functions', `${fnId}.js`);
const fnBundledPath = path.join(options.outputDirectory, fnFileRelative);
Expand Down
8 changes: 5 additions & 3 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const run = async() => {
throw new Error('An output option must be specified the --manifest flag is not set')
}

const workingDirectory = path.join(Deno.cwd(), source||"");
const outputDirectory = output ? path.join(Deno.cwd(), output||"") : undefined;
const workingDirectory = path.isAbsolute(source||"") ? source : path.join(Deno.cwd(), source||"");
const outputDirectory = output ? (path.isAbsolute(output) ? output : path.join(Deno.cwd(), output||"")) : undefined;

const options: Options = {
manifestOnly,
Expand All @@ -24,11 +24,13 @@ const run = async() => {
// deno-lint-ignore no-explicit-any
log: (...args: any) => console.log(...args),
}

// Disable logging to stdout if we're outputing a manifest.json file to stdout
if(options.manifestOnly) {
options.log = () => {}
}

options.log(options);

// Generate Manifest
const generatedManifest = await createManifest(options);
Expand Down

0 comments on commit 6a7edb7

Please sign in to comment.