1000ch / atom-svgo

Minify SVG with SVGO 🐯
https://atom.io/packages/svgo
MIT License
14 stars 5 forks source link

Deletes the whole content of the file when minifying or prettifying #7

Closed BlackSkorpio closed 7 years ago

BlackSkorpio commented 8 years ago

Running Atom 1.8.0+SVGO 2.12 on Win7

When trying to minify/prettifying a file either via the menu or CTRL+SHIFT+O SVGO deletes all content from the file.

1000ch commented 8 years ago

BTW,

  1. Occur without shortcut key (package menu)?
  2. Would you try installing apm install svgo alternatively?
BlackSkorpio commented 8 years ago
  1. It happens no matter what option I choose to use to minify the file
  2. Where should I run that command, tried in it the atom command palette to no avail
rugk commented 8 years ago

I can reproduce this too, but only on my Windows installation with Atom 1.9.9. On Linux it works fine.

BlackSkorpio commented 8 years ago

Issue is still there in v2.2.0, with Win7 Atom 1.9.9

1000ch commented 8 years ago

@BlackSkorpio

Where should I run that command, tried in it the atom command palette to no avail

Try in CLI such as Terminal.app or iTerm.app?

BlackSkorpio commented 8 years ago

Thnx, figured it out...

That took me a step further. But instead generates this error when trying to minify a svg

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".

C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\csso\lib\compressor\index.js:109

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
    at compress (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\csso\lib\compressor\index.js:109:74)
    at minify (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\csso\lib\index.js:80:9)
    at Object.minifyBlock (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\csso\lib\index.js:106:12)
    at Object.exports.fn (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\plugins\minifyStyles.js:38:42)
    at C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\plugins.js:59:45
    at Array.filter (native)
    at monkeys (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\plugins.js:46:39)
    at perItem (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\plugins.js:77:12)
    at C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\plugins.js:18:24
    at Array.forEach (native)
    at module.exports (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\plugins.js:14:13)
    at C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo.js:63:17
    at Object.sax.onend (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\svg2js.js:156:13)
    at emit (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\sax\lib\sax.js:640:35)
    at end (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\sax\lib\sax.js:683:5)
    at Object.write (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\sax\lib\sax.js:991:14)
    at Object.SAXParser.close (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\node_modules\sax\lib\sax.js:157:38)
    at module.exports (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo\svg2js.js:169:28)
    at SVGO._optimizeOnce (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo.js:56:5)
    at SVGO.optimize (C:\Users\user_name\.atom\packages\svgo\node_modules\svgo\lib\svgo.js:49:11)
    at minify (C:\Users\user_name\.atom\packages\svgo\index.js:20:21)
    at atom-workspace.<anonymous> (C:\Users\user_name\.atom\packages\svgo\index.js:28:60)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (C:\Users\user_name\AppData\Local\atom\app-1.9.9\resources\app.asar\src\command-registry.js:260:29)
    at CommandRegistry.handleCommandEvent (C:\Users\user_name\AppData\Local\atom\app-1.9.9\resources\app.asar\src\command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (C:\Users\user_name\AppData\Local\atom\app-1.9.9\resources\app.asar\src\command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (C:\Users\user_name\AppData\Local\atom\app-1.9.9\resources\app.asar\src\atom-environment.js:1104:28)
    at EventEmitter.outerCallback (C:\Users\user_name\AppData\Local\atom\app-1.9.9\resources\app.asar\src\application-delegate.js:329:25)
    at emitTwo (events.js:100:13)
    at EventEmitter.emit (events.js:185:7)
The error was thrown from the svgo package.
BlackSkorpio commented 8 years ago

This error was also reported here #4 My current SVGO version is: 2.4.0

rugk commented 8 years ago

So is eval the issue?

BlackSkorpio commented 8 years ago

Thats the error it put out right now.

Nargilia commented 8 years ago

same problem

rugk commented 8 years ago

I don't know what CSP Atom uses and how you can influence this, but the error certainly is there somewhere. The best way to fix this would probably be to get rid of any eval things.

1000ch commented 7 years ago

@BlackSkorpio @Nargilia @rugk Still occur?

BlackSkorpio commented 7 years ago

Now we (I) get another error image

Good news it dont deletes all content, it's only refuses to minifying it :/

The full error log shows:

Error: Notification must be created with string message: Error: spawn C:\Users\Bjarne Varöystrand\.atom\packages\svgo\node_modules\.bin\svgo.cmd ENOENT
    at Notification.module.exports.Notification.validate (C:\Users\Bjarne Varöystrand\AppData\Local\atom\app-1.12.7\resources\app.asar\src\notification.js:25:15)
    at new Notification (C:\Users\Bjarne Varöystrand\AppData\Local\atom\app-1.12.7\resources\app.asar\src\notification.js:20:12)
    at NotificationManager.module.exports.NotificationManager.addError (C:\Users\Bjarne Varöystrand\AppData\Local\atom\app-1.12.7\resources\app.asar\src\notification-manager.js:41:35)
    at ChildProcess.<anonymous> (C:\Users\Bjarne Varöystrand\.atom\packages\svgo\index.js:36:24)
    at emitOne (events.js:96:13)
    at ChildProcess.emit (events.js:188:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
1000ch commented 7 years ago

@BlackSkorpio It seems to be fixed with newest version 🙏