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

build-elm-assets

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-elm-assets - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

16

index.js

@@ -27,3 +27,3 @@ const dive = require("dive");

const elmName = createElmName(copyTo);
moveAssets(copyFrom, copyTo, urlWithHash, config);
copyAsset(copyFrom, urlWithHash, config);
assets.push({ urlWithHash, elmName });

@@ -38,10 +38,6 @@ },

function moveAssets(copyFrom, copyTo, link, { assetsOutputPath, assetsLink }) {
if (isString(assetsOutputPath)) {
const destination = path.join(assetsOutputPath, copyTo);
fs.copySync(copyFrom, destination);
if (isString(assetsLink)) {
fs.ensureSymlinkSync(destination, path.join(assetsLink, link));
}
}
function copyAsset(copyFrom, copyTo, { assetsOutputPath }) {
if (!isString(assetsOutputPath)) return;
const destination = path.join(assetsOutputPath, copyTo);
fs.copySync(copyFrom, destination);
}

@@ -170,5 +166,5 @@

createElmName,
moveAssets,
copyAsset,
validateConfig,
writeElmFile
};
{
"name": "build-elm-assets",
"version": "1.1.0",
"version": "1.2.0",
"description": "builds a elm file containing all paths of a assets directory",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,7 +16,4 @@ Build Elm Assets

assetsPath: path.join("app", "assets", "images"),
// asset gets copied to this folder if provided
assetsOutputPath: path.join("public/copies"),
// link to assetsOutputPath with hash goes here
// this is only useful when you copy the file using assetsOutputPath
assetsLink: path.join("public"),
// assets get copied to this folder if provided with the url created with buildUrl
assetsOutputPath: path.join("public"),
// function to modify the asset path this path will be passed to buildUrl

@@ -23,0 +20,0 @@ replacePath: fileName => fileName.replace(/.*\/app\/assets\/images\//, ""),

@@ -79,41 +79,25 @@ import test from "ava";

test("moveAssets", t => {
test("copyAsset", t => {
mock("fs-extra", {
copySync: (s, d) => {
t.deepEqual(s, "app/assets/foo.png");
t.deepEqual(d, "public/test/assets/foo.png");
},
ensureSymlinkSync: (s, d) => {
t.deepEqual(s, "public/test/assets/foo.png");
t.deepEqual(d, "public/assets/foo-hash.png");
t.deepEqual(d, "public/test/assets/foo-hash.png");
}
});
const { moveAssets } = mock.reRequire("./index.js");
const { copyAsset } = mock.reRequire("./index.js");
const config = {
assetsOutputPath: "public/test",
assetsLink: "public/"
assetsOutputPath: "public/test"
};
moveAssets(
"app/assets/foo.png",
"assets/foo.png",
"assets/foo-hash.png",
config
);
copyAsset("app/assets/foo.png", "assets/foo-hash.png", config);
});
test("moveAssets doesn't link or copy if not configured", t => {
test("copyAsset doesn't copy if not configured", t => {
mock("fs-extra", {
copySync: () => t.fail(),
ensureSymlinkSync: () => t.fail()
copySync: () => t.fail()
});
const { moveAssets } = mock.reRequire("./index.js");
const { copyAsset } = mock.reRequire("./index.js");
const config = {};
moveAssets(
"app/assets/foo.png",
"assets/foo.png",
"assets/foo-hash.png",
config
);
copyAsset("app/assets/foo.png", "assets/foo-hash.png", config);
t.pass();

@@ -120,0 +104,0 @@ });

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