Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-inline-svg

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-inline-svg - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

tests/dummy/app/templates/class.hbs

12

app/helpers/inline-svg.js

@@ -9,3 +9,11 @@ import Ember from 'ember';

export function inlineSvg(path, options) {
var svg = Ember.get(SVGs, dottify(path));
var jsonPath = dottify(path);
var svg = Ember.get(SVGs, jsonPath);
// TODO: Ember.get should return `null`, not `undefined`.
// if (svg === null && /\.svg$/.test(path))
if (typeof svg === "undefined" && /\.svg$/.test(path)) {
svg = Ember.get(SVGs, jsonPath.slice(0, -4));
}
Ember.assert("No SVG found for "+path, svg);

@@ -19,2 +27,2 @@

export default Ember.Handlebars.makeBoundHelper(inlineSvg);
export default Ember.Handlebars.makeBoundHelper(inlineSvg);

@@ -5,2 +5,10 @@ # CHANGELOG

## v0.1.0
* #5 The path to an image can now optionally have a `.svg` extension.
* #6 The default source directory changed from `./public/images` to `./public`.
* #7 If there is an error during SVG optimization, the build is now aborted and a descriptive error is displayed.
* #7 If there are no images present, nothing happens and the build continues. [More info](https://github.com/minutebase/ember-inline-svg/issues/1#issuecomment-70625510).
* #9 Refactored tests to be independent of one another.
## v0.0.3

@@ -16,2 +24,2 @@

* initial release
* initial release

27

index.js
/* jshint node: true */
'use strict';
var fs = require('fs');
var merge = require('merge')
var mergeTrees = require('broccoli-merge-trees');
var flattenFolder = require('broccoli-spelunk');
var pickFiles = require('broccoli-static-compiler');
var SVGOptmizer = require('./svg-optimizer');
var fs = require('fs');
var merge = require('merge')
var mergeTrees = require('broccoli-merge-trees');
var flatiron = require('broccoli-flatiron');
var Funnel = require('broccoli-funnel');
var SVGOptmizer = require('./svg-optimizer');

@@ -16,3 +16,3 @@ module.exports = {

return merge(true, {}, {
paths: ['public/images'],
paths: ['public'],
optimize: { /* svgo defaults */ }

@@ -24,3 +24,3 @@ }, this.app.options.svg || {});

if (this.isDevelopingAddon()) {
return ['tests/dummy/public/images'];
return ['tests/dummy/public'];
}

@@ -44,6 +44,4 @@ return this.options().paths;

svgs = pickFiles(svgs, {
srcDir: '/',
files: ['**/*.svg'],
destDir: '/'
svgs = new Funnel(svgs, {
include: [new RegExp(/\.svg$/)]
});

@@ -53,6 +51,5 @@

svgs = flattenFolder(svgs, {
svgs = flatiron(svgs, {
outputFile: 'svgs.js',
mode: 'es6',
keepExtensions: false
trimExtensions: true
});

@@ -59,0 +56,0 @@

{
"name": "ember-inline-svg",
"description": "Ember CLI addon to render SVG images inline",
"version": "0.0.3",
"version": "0.1.0",
"directories": {

@@ -48,4 +48,4 @@ "doc": "doc",

"broccoli-merge-trees": "^0.2.1",
"broccoli-spelunk": "^0.1.2",
"broccoli-static-compiler": "^0.2.1",
"broccoli-flatiron": "^0.0.0",
"broccoli-funnel": "^0.1.7",
"merge": "^1.2.0",

@@ -52,0 +52,0 @@ "mkdirp": "^0.5.0",

@@ -32,2 +32,8 @@ var CachingWriter = require('broccoli-caching-writer');

svgo.optimize(rawSVG, function(result) {
if (result.error) {
var error = new Error(result.error);
error.file = relativePath;
return reject(error);
}
fs.writeFileSync(destPath, result.data, { encoding: 'utf8'});

@@ -41,2 +47,2 @@ resolve();

}
});
});

@@ -16,3 +16,3 @@ import Ember from 'ember';

test('displays SVG at root', function() {
visit('/');
visit('/root');

@@ -25,3 +25,3 @@ andThen(function() {

test('displays SVG in subdirectory', function() {
visit('/');
visit('/subdirectory');

@@ -34,7 +34,15 @@ andThen(function() {

test('adds class to SVG', function() {
visit('/');
visit('/class');
andThen(function() {
ok(find(".kiwi-image-in-directory svg.with-a-class").length, "has added the class");
ok(find(".kiwi-image-with-a-class svg.with-a-class").length, "has added the class");
});
});
});
test('trims unnecessary .svg` extension', function() {
visit('/extension');
andThen(function() {
ok(find(".kiwi-image-with-extension svg").length, "has an SVG, extension was trimmed");
});
});

@@ -9,4 +9,8 @@ import Ember from 'ember';

Router.map(function() {
this.route("root");
this.route("subdirectory");
this.route("class");
this.route("extension");
});
export default Router;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc