Coder Social home page Coder Social logo

electron-icns-ex's People

Stargazers

 avatar

Watchers

 avatar

electron-icns-ex's Issues

Can't make it work

Hi, I'm trying to create a node util to find some apps by name, and get an object with name,path,icon
I already got the part to get the apps, and now I want to convert the icns to base64 but string is always empty and no error..
this is what I have on a simple test.js

const { parseIcnsToBase64, parseIcnsToBase64Sync } = require('electron-icns-ex');

const getAppInfo = (path) => {
  const name = path.match(/([\w\d\s_-]*)\.?[^\\\/]*$/)[1];
  const icnsFile = getCFBundleIconFileSync(path);
  const icnsPath = `${path.replaceAll(' ', '\\ ')}/Contents/Resources/${icnsFile}`;
  const icon = parseIcnsToBase64Sync(icnsPath);

  return {
    name,
    path,
    icon 
  }
}

const getCFBundleIconFileSync = (appPath) => {
    const plistPath = `${appPath.replaceAll(' ', '\\ ')}/Contents/Info.plist`;
    const getIconFilenameCmd = `plutil -convert xml1 -o - ${plistPath} | sed -n '/CFBundleIconFile/,/\\//p' | sed -n '/<string>/,/<\\/string>/p' | sed 's/string>/\/g' | sed 's/<//g' | sed 's/\\///g' | awk '{$1=$1};1'`;
    return execSync(getIconFilenameCmd).toString();
}

Do I have to do anything else besides install the package with npm?

pngPath is not defined

Could you help me to figure out what am I missing?

    const icns = require('electron-icns-ex');
    parseIcnsToPNG(localIconPath, pngPath);                         // localIconPath defined erlier in the code
    const img = document.querySelector("#localIcon");
    img.src = pngPath;

error:
pngPath is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.