How to use the junk.is function in junk

To help you get started, we’ve selected a few junk 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 electerious / Rosid / src / copy.js View on Github external
const filter = (filePath) => {

		// The filePath is absolute, but should be relative as micromatch will
		// match against the relative path of the routes. Matching against
		// an absolute path requires the use of path.join which causes issues on Windows:
		// https://github.com/micromatch/micromatch/issues/95
		filePath = path.relative(srcPath, filePath)

		const fileName = path.parse(filePath).base

		const isIgnored = mm.any(filePath, ignoredFiles)
		const isJunk = junk.is(fileName)

		// Copy file when it's not ignored or not junk
		const copy = isIgnored === false && isJunk === false

		if (opts.verbose === true) {

			if (copy === false) log(`{cyan:Skipping file: {grey:${ filePath }`)
			if (copy === true) log(`{cyan:Copying file: {grey:${ filePath }`)

		}

		// Return true to include, false to exclude
		return copy

	}
github gielcobben / caption / app / scripts / Utility.js View on Github external
fs.readdirSync(file.path).map(fileInDirectory => {
          // Get stats for each file in directory so we can add the size of the file in the object instead of the size of the folder.
          const fileName = fileInDirectory;
          const filePath = `${file.path}/${fileInDirectory}`;
          const fileInDirectoryStats = fs.statSync(filePath);
          const fileSize = fileInDirectoryStats.size;
          const fileExtention = fileName.substr(fileName.lastIndexOf(".") + 1);

          if (Junk.is(fileInDirectory)) {
            // Check if file is junk (Think on files like DS_Store ect..)
            return false;
          } else {
            // Map and push the file object in array
            const fileObject = {
              extention: fileExtention,
              size: fileSize,
              name: fileName,
              path: filePath,
              status: "loading"
            };

            // Push
            files.push(fileObject);
          }
        });
github electerious / Rosid / src / deliver.js View on Github external
const eventHandler = function(bs, event, filePath) {

	const fileName = path.parse(filePath).base
	const fileExtension = path.extname(filePath)

	// Ignore change when filePath is junk
	if (junk.is(fileName) === true) return

	// Flush the cache no matter what event was send by Chokidar.
	// This ensures that we serve the latest files when the user reloads the site.
	cache.flush(filePath)

	const styleExtensions = [
		'.css',
		'.scss',
		'.sass',
		'.less'
	]

	// Reload stylesheets when the file extension is a known style extension
	if (styleExtensions.includes(fileExtension) === true) return bs.reload('*.css')

	const imageExtensions = [
github post-tracker / site / scripts / build.js View on Github external
recursive( gameFilesPath, ( gameFilesError, gameFiles ) => {
        if ( gameFilesError ) {
            console.log( `No game files found for ${ gameData.identifier } ` );
            gameFiles = [];
        }

        for ( const filename of gameFiles ) {
            if ( junk.is( path.parse( filename ).base ) ) {
                continue;
            }

            if ( filename.includes( 'styles.css' ) ) {
                gameData.styles = fs.readFileSync( filename );
            }

            if ( filename.includes( 'assets/logo.png' ) ) {
                gameData.logo = '<img class="header-logo" src="assets/logo.png">';
            }

            savefile( path.join( gameData.identifier, filename.replace( gameFilesPath, '' ) ), fs.readFileSync( filename ) );
        }

        if ( !gameData.logo ) {
            gameData.logo = gameData.shortName;
github timkendrick / recursive-copy / lib / copy.js View on Github external
function junkFilter(relativePath) {
	var filename = path.basename(relativePath);
	return !junk.is(filename);
}
github ganeshrvel / openmtp / mtp-kernel / index.js View on Github external
}) {
    if (!this.device) return this.throwMtpError();

    try {
      if (!existsSync(folderPath)) {
        return Promise.resolve({
          data: null,
          error: MTP_ERROR_FLAGS.LOCAL_FOLDER_NOT_FOUND
        });
      }

      const files = readdirSync(folderPath);
      for (let i = 0; i &lt; files.length; i += 1) {
        const file = files[i];

        if (!junk.is(file)) {
          const fullPath = join(folderPath, file);
          const stats = lstatSync(fullPath);
          const isFolder = stats.isDirectory();
          const fileInfo = {
            id: quickHash(fullPath),
            name: file,
            size: stats.size,
            isFolder,
            path: fullPath,
            children: []
          };

          if (isWritable(fullPath)) {
            const lastIndex = fileTreeStructure.push(fileInfo) - 1;

            if (isFolder &amp;&amp; recursive) {
github sx1989827 / DOClever / node_modules / recursive-copy / lib / copy.js View on Github external
function junkFilter(relativePath) {
	var filename = path.basename(relativePath);
	return !junk.is(filename);
}

junk

Filter out system junk files like .DS_Store and Thumbs.db

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Popular junk functions