How to use the upath.extname function in upath

To help you get started, we’ve selected a few upath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / webpack-plugin / src / resolve-template.js View on Github external
function getPath(input, lazy, bundle) {
  const extension = path.extname(input);
  let output = '';
  // for .css files force the request to the css loader (https://github.com/aurelia/webpack-plugin/issues/11#issuecomment-212578861)
  if (extension == ".css")
    output += `!!css!`;
  if (lazy || bundle)
    output += `bundle?`;
  if (lazy)
    output += `lazy`;
  if (lazy && bundle)
    output += `&`;
  if (bundle)
    output += `name=${bundle}`;
  if (lazy || bundle)
    output += `!`;
  return `${output}${input}`
}
github GoogleChrome / workbox / packages / workbox-cli / src / lib / questions / ask-extensions-to-cache.js View on Github external
ignore: [
        ...ignoredDirectories.map((directory) => `**/${directory}/**`),
        ...ignoredFileExtensions.map((extension) => `**/*.${extension}`),
      ],
    }, (error, files) => {
      if (error) {
        reject(error);
      } else {
        resolve(files);
      }
    });
  });

  const extensions = new Set();
  for (const file of files) {
    const extension = upath.extname(file);
    if (extension) {
      // Get rid of the leading . character.
      extensions.add(extension.replace(/^\./, ''));
    }
  }

  return [...extensions];
}
github cosmicjs / cosmic-cli / non_standard_commands / add-media.js View on Github external
function handler(options) {
  var invokedCmd = options.invokedCmd
  var bucket = options.bucket
  
  var buffer = fs.readFileSync(invokedCmd.file)

  var fileExt = upath.extname(invokedCmd.file)
  var originalname = upath.defaultExt(invokedCmd.title || 'media', fileExt)
  var media_object = { originalname: originalname, buffer: buffer }

  bucket.addMedia({
    media: media_object,
    folder: invokedCmd.folder,
  }).then(function(res) {
    print.success('Success')
    console.log(res)
    process.exit()
  }).catch(function(err) {
    print.error('Error')
    console.log(err)
    process.exit(1)
  })
}
github jus / jus / lib / plugins / stylesheetSTYL.js View on Github external
static check (filename, callback) {
    const extension = path.extname(filename).toLowerCase()
    const allowedExtensions = ['.styl']
    return callback(null, allowedExtensions.indexOf(extension) > -1)
  }
github pingyhq / pingy-cli / packages / compile / lib / baby-tolk.js View on Github external
function listPotentialSourceFiles(compiledFile) {
  const compiledExtension = Path.extname(compiledFile);
  const targetExtensions = sourceExtension[compiledExtension] || [];

  return targetExtensions.map(extension =>
    compiledFile.replace(compiledExtension, extension)
  );
}
github aurelia / webpack-plugin / src / resolve-template.js View on Github external
readdir(targetDir, [(file, stats) => 
      path.extname(file) !== extension && !stats.isDirectory()
    ], (error, files) => error ? reject(error) : resolve(files)));
github pixelnest / presskit.html / lib / core / generator.js View on Github external
function isDataFile (filename) {
  const ext = path.extname(filename)
  const filenameWithoutExt = path.basename(filename, ext)

  return filenameWithoutExt === 'data' && ext === '.xml'
}
github jus / jus / lib / plugins / standard / datafile-std.js View on Github external
check: (filename, callback) => {
    const extension = path.extname(filename).toLowerCase()
    const allowedExtensions = ['.json', '.yml', '.yaml']

    return callback(null, allowedExtensions.indexOf(extension) > -1)
  },
github jus / jus / lib / plugins / cupboard / datafileYAML.js View on Github external
check: (filename, callback) => {
    const extension = path.extname(filename).toLowerCase()
    const allowedExtensions = ['.yml', '.yaml']
    return callback(null, allowedExtensions.indexOf(extension) > -1)
  },
github jus / jus / lib / plugins / stylesheetCSS.js View on Github external
static check (filename, callback) {
    const extension = path.extname(filename).toLowerCase()
    const allowedExtensions = ['.css']
    return callback(null, allowedExtensions.indexOf(extension) > -1)
  }

upath

A proxy to `path`, replacing `\` with `/` for all results (supports UNC paths) & new methods to normalize & join keeping leading `./` and add, change, default, trim file extensions.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis