"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/plugins/rubygems/inspectors/gemspec.ts" (20 Feb 2024, 901 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import * as path from 'path';
    2 import { Files, tryGetSpec } from './try-get-spec';
    3 import { Spec } from './index';
    4 
    5 const pattern = /\.gemspec$/;
    6 
    7 export function canHandle(file: string): boolean {
    8   return !!file && pattern.test(file);
    9 }
   10 
   11 export async function gatherSpecs(root: string, target: string): Promise<Spec> {
   12   const targetName = path.basename(target);
   13   const targetDir = path.dirname(target);
   14   const files: Files = {};
   15 
   16   const gemspec = await tryGetSpec(root, path.join(targetDir, targetName));
   17 
   18   if (gemspec) {
   19     files.gemspec = gemspec;
   20   } else {
   21     throw new Error(`File not found: ${target}`);
   22   }
   23 
   24   const gemfileLock = await tryGetSpec(
   25     root,
   26     path.join(targetDir, 'Gemfile.lock'),
   27   );
   28 
   29   if (gemfileLock) {
   30     files.gemfileLock = gemfileLock;
   31   }
   32 
   33   return {
   34     packageName: path.basename(root),
   35     targetFile: path.join(targetDir, targetName),
   36     files,
   37   };
   38 }