How to use the pn/fs.existsSync function in pn

To help you get started, we’ve selected a few pn 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 MarshallOfSound / Google-Play-Music-Desktop-Player-UNOFFICIAL- / vendor / svg_raster.js View on Github external
fileMappings[srcFile].forEach((targetFile) => {
        const filePath = path.resolve(basePath, `${srcFile}${type ? `_${type}` : ''}.svg`);
        if (!fs.existsSync(filePath)) return;
        fs.readFile(filePath)
            .then((src) => svg2png(src, { width: targetFile.width, height: targetFile.height }))
            .then(buffer => {
              mkdirp.sync(path.dirname(path.resolve(typeTargetPath, `${targetFile.name}.png`)));
              return fs.writeFile(path.resolve(typeTargetPath, `${targetFile.name}.png`), buffer);
            })
            .then(doIcons.bind(this, type, typeTargetPath))
            .catch(e => console.error(e));
      });
    });