How to use junk - 10 common examples

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 OrgCurrent / Android / node / bower / lib / core / resolvers / FsResolver.js View on Github external
.then(function (files) {
        var file;
        var oldPath;
        var newPath;

        // Remove any OS specific files from the files array
        // before checking its length
        files = files.filter(junk.isnt);

        // Only rename if there's only one file and it's not the json
        if (files.length === 1 && !/^(bower|component)\.json$/.test(files[0])) {
            file = files[0];
            this._singleFile = 'index' + path.extname(file);
            oldPath = path.join(this._tempDir, file);
            newPath = path.join(this._tempDir, this._singleFile);

            return Q.nfcall(fs.rename, oldPath, newPath);
        }
    }.bind(this));
};
github bower / bower / lib / core / resolvers / UrlResolver.js View on Github external
function(files) {
            var file;
            var oldPath;
            var newPath;

            // Remove any OS specific files from the files array
            // before checking its length
            files = files.filter(junk.isnt);

            // Only rename if there's only one file and it's not the json
            if (
                files.length === 1 &&
                !/^(component|bower)\.json$/.test(files[0])
            ) {
                file = files[0];
                this._singleFile = 'index' + path.extname(file);
                oldPath = path.join(this._tempDir, file);
                newPath = path.join(this._tempDir, this._singleFile);

                return Q.nfcall(fs.rename, oldPath, newPath);
            }
        }.bind(this)
    );
github bower / bower / lib / core / resolvers / FsResolver.js View on Github external
function(files) {
            var file;
            var oldPath;
            var newPath;

            // Remove any OS specific files from the files array
            // before checking its length
            files = files.filter(junk.isnt);

            // Only rename if there's only one file and it's not the json
            if (
                files.length === 1 &&
                !/^(bower|component)\.json$/.test(files[0])
            ) {
                file = files[0];
                this._singleFile = 'index' + path.extname(file);
                oldPath = path.join(this._tempDir, file);
                newPath = path.join(this._tempDir, this._singleFile);

                return Q.nfcall(fs.rename, oldPath, newPath);
            }
        }.bind(this)
    );
github OrgCurrent / Android / node / bower / lib / core / resolvers / UrlResolver.js View on Github external
.then(function (files) {
        var file;
        var oldPath;
        var newPath;

        // Remove any OS specific files from the files array
        // before checking its length
        files = files.filter(junk.isnt);

        // Only rename if there's only one file and it's not the json
        if (files.length === 1 && !/^(component|bower)\.json$/.test(files[0])) {
            file = files[0];
            this._singleFile = 'index' + path.extname(file);
            oldPath = path.join(this._tempDir, file);
            newPath = path.join(this._tempDir, this._singleFile);

            return Q.nfcall(fs.rename, oldPath, newPath);
        }
    }.bind(this));
};
github getgridea / gridea / src / server / renderer.ts View on Github external
async renderCustomPage() {
    const files = fse.readdirSync(urlJoin(this.themePath, 'templates'), { withFileTypes: true })
    const customTemplates = files
      .filter(item => !item.isDirectory())
      .map(item => item.name)
      .filter(junk.not)
      .filter((name: string) => {
        return ![
          'index.ejs',
          'post.ejs',
          'tag.ejs',
          'tags.ejs',
          'archives.ejs',
          // 👇 Gridea protected word, because these filename is gridea folder's name
          'images.ejs',
          'media.ejs',
          'post-images.ejs',
          'styles.ejs',
          'tag.ejs',
          'tags.ejs',
        ].includes(name)
      })
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 ippontech / tatami / web / node_modules / bower / lib / util / extract.js View on Github external
.then(function (files) {
        var singleDir;

        // Remove any OS specific files from the files array
        // before checking its length
        files = files.filter(junk.isnt);

        if (files.length !== 1) {
            return false;
        }

        singleDir = path.join(dir, files[0]);

        return Q.nfcall(fs.stat, singleDir)
        .then(function (stat) {
            return stat.isDirectory() ? singleDir : false;
        });
    });
}
github hw2-archive / upt / src / lib / util / extract.js View on Github external
.then(function (files) {
                var singleDir;

                // Remove any OS specific files from the files array
                // before checking its length
                files = files.filter(junk.isnt);

                if (files.length !== 1) {
                    return false;
                }

                singleDir = path.join(dir, files[0]);

                return Q.nfcall(fs.stat, singleDir)
                        .then(function (stat) {
                            return stat.isDirectory() ? singleDir : false;
                        });
            });
}

junk

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

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular junk functions