@figma-export/output-components-as-es6
Advanced tools
Comparing version 0.0.1-alpha.0 to 0.0.1-alpha.3
32
index.js
const fs = require('fs'); | ||
const path = require('path'); | ||
const camelCase = (str) => { | ||
return str.replace(/^([A-Z])|[\s-_]+(\w)/g, function (match, p1, p2, offset) { | ||
if (p2) return p2.toUpperCase(); | ||
return p1.toLowerCase(); | ||
}); | ||
}; | ||
const camelCase = (str) => str.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => { | ||
if (p2) return p2.toUpperCase(); | ||
return p1.toLowerCase(); | ||
}); | ||
module.exports = options => { | ||
module.exports = (options) => { | ||
if (!fs.existsSync(options.output)) { | ||
const err = new Error(`Folder '${options.output}' doesn't exist`) | ||
throw err | ||
const err = new Error(`Folder '${options.output}' doesn't exist`); | ||
throw err; | ||
} | ||
return async pages => { | ||
return async (pages) => { | ||
let code = ''; | ||
Object.entries(pages).forEach(([pageName, page]) => { | ||
Object.entries(pages).forEach(([, page]) => { | ||
Object.entries(page).forEach(([filename, { svg }]) => { | ||
@@ -30,8 +27,7 @@ const variableName = camelCase(filename); | ||
fs.writeFile(path.resolve(options.output, 'figma-components' + '.js'), code, | ||
err => { | ||
fs.writeFile(path.resolve(options.output, 'figma-components.js'), code, | ||
(err) => { | ||
if (err) throw err; | ||
} | ||
) | ||
} | ||
} | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "@figma-export/output-components-as-es6", | ||
"version": "0.0.1-alpha.0", | ||
"version": "0.0.1-alpha.3", | ||
"description": "Outputter for @figma-export that exports components in javascript file", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/marcomontalbano/figma-exporter.git", | ||
"url": "git+https://github.com/marcomontalbano/figma-exporter.git", | ||
"directory": "packages/output-components-as-es6" | ||
@@ -17,6 +17,3 @@ }, | ||
}, | ||
"scripts": { | ||
"test": "echo \"Run tests from root\" && exit 1" | ||
}, | ||
"gitHead": "6a17670653a172c28d67bdbd8de14ab52123feba" | ||
"gitHead": "e2a08c659f0b4385d7bcbc570624c7714a87bf94" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2042
28