How to use the junk.not 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 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 webframes / webframes / test / util.js View on Github external
fs.readdirSync(filesPath).forEach( function(fileName)
	{
		if (junk.not(fileName))
		{
			files.push( filesPath +"/"+ fileName );
		}
	});
github alibaba / ice / packages / iceworks-server / src / lib / scanDirectory.ts View on Github external
await Promise.all(files.map(async (filename: string) => {
    const targetPath = path.join(directoryPath, filename);
    let stats;
    try {
      stats = await lstatAsync(targetPath);
    } catch (err) {
      console.warn('lstatAsync got error:', err);
    }

    const isDirectory = stats &&
      stats.isDirectory() &&
      junk.not(filename) &&
      filename.indexOf('.') !== 0;
    if (isDirectory) {
      try {
        await accessAsync(targetPath, fs.constants.R_OK);
        targetFiles.push(filename);
      } catch (error) {
        console.warn('accessAsync got error:', error);
      }
    }
  }));
github getgridea / gridea / src / server / theme.ts View on Github external
async getThemeList() {
    let themes = await fse.readdir(this.themeDir)
    themes = themes.filter(junk.not)
    const result = await Promise.all(themes.map(async (item: string) => {
      const data = {
        folder: item,
        name: item,
        version: '',
        author: '',
        repository: '',
      }
      const themeConfigPath = path.join(this.themeDir, item, 'config.json')
      if (fse.existsSync(themeConfigPath)) {
        const config = fse.readJSONSync(themeConfigPath)
        data.name = config.name
        data.version = config.version
        data.author = config.repository
        data.repository = config.repository
      }
github sindresorhus / cpy / index.js View on Github external
				files = files.filter(file => junk.not(path.basename(file)));
			}
github imagemin / imagemin / index.js View on Github external
			.filter(filePath => junk.not(path.basename(filePath)))
			.map(async filePath => {
github alibaba / ice / tools / iceworks / renderer / src / pages / Home / ProjectDashboard / Assets.jsx View on Github external
recursiveReaddirSync = (dirPath, rootDir) => {
    let stats;
    let list = [];
    const files = fs.readdirSync(dirPath).filter(junk.not);

    files.forEach((file) => {
      const fullPath = path.join(dirPath, file);
      stats = fs.lstatSync(fullPath);
      if (stats.isDirectory()) {
        list = list.concat(this.recursiveReaddirSync(fullPath, rootDir));
      } else {
        list.push({
          path: path.relative(rootDir, fullPath),
          size: filesize(stats.size),
          fullPath,
          statsSize: stats.size,
        });
      }
    });
    list = list.sort((a, b) => {
github alibaba / ice / tools / iceworks / renderer / src / pages / Home / ProjectDashboard / Aliyun.jsx View on Github external
recursiveReaddirSync = (dirPath, rootDir) => {
    let stats;
    let list = [];
    const files = fs.readdirSync(dirPath).filter(junk.not);

    files.forEach((file) => {
      const fullPath = path.join(dirPath, file);
      stats = fs.lstatSync(fullPath);
      if (stats.isDirectory()) {
        list = list.concat(this.recursiveReaddirSync(fullPath, rootDir));
      } else {
        list.push({
          path: path.relative(rootDir, fullPath),
          fullPath,
        });
      }
    });
    list = list.sort((a, b) => {
      return a.path.localeCompare(b.path);
    });
github SamVerschueren / clinton / lib / environment.js View on Github external
.filter(item => {
						const base = path.basename(item);
						return junk.not(base) && base.indexOf('_') !== 0;
					})
					.filter(file => !isDir.sync(path.join(this.path, file)));
github alibaba / ice / tools / iceworks / renderer / src / lib / file-system.js View on Github external
export const readdirSync = (targetPath) => {
  if (pathExists.sync(targetPath)) {
    return fs.readdirSync(targetPath).filter(junk.not);
  }
  return [];
};

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