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AAK,KAAK,SAAU,EAAS,QAAQ,QAAS,QAAS,EAAI,IAE3E,MAAM,QAAQ,MAAK,IAG5B,QAAQ,IAAI,EAAS","file":"/npm/ss-to-react@0.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ss-to-react@0.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n'use strict';\n\nconst yargs = require('yargs');\nconst path = require('path');\nconst fs = require('fs');\nconst glob = require('glob');\nconst HTMLtoJSX = require('htmltojsx');\n\nconst argv = yargs\n    .command('$0 <source> <dest>')\n    .help()\n    .argv;\n\nconst sourcePath = path.resolve(argv.source);\nconst destPath = path.resolve(argv.dest);\n\nif (!fs.existsSync(sourcePath)) {\n    throw new Error(`Source path ${sourcePath} does not exist`);\n} \nif (!fs.existsSync(destPath)) {\n    throw new Error(`Destination path ${sourcePath} does not exist`);\n} \n\nconst read = sourcePath => (\n    new Promise((resolve, reject) => {\n        fs.readFile(sourcePath, (err, data) => {\n            if (err) {\n                reject(err);\n            } else {\n                resolve(data.toString());\n            }\n        });\n    })\n);\nconst write = (target, contents) => (\n    new Promise((resolve, reject) => {\n        const dir = path.dirname(target);\n        if (!fs.existsSync(dir)) {\n            fs.mkdirSync(dir, { recursive: true});\n        }\n        fs.writeFile(target, contents, (err) => {\n            if (err) {\n                reject(err);\n            } else {\n                resolve();\n            }\n        });\n    })\n);\nconst converter = new HTMLtoJSX({\n    createClass: false,\n});                \n\nglob(`${sourcePath}/**/*.ss`, (err, files) => {\n    const promises = files.map(f => {\n        const pathname = path.relative(sourcePath, f);\n        const componentName = path.basename(f, '.ss');\n        return read(path.join(sourcePath, pathname))\n            .then(contents => { \n                let jsx = contents.replace(/(<%)(.+?)(%>)/g,`<!-- $2 -->`);\n                try {\n                    jsx = converter.convert(jsx);\n                    jsx = jsx.split(\"\\n\")\n                            .map(line => `\\t\\t${line}`)\n                            .join(\"\\n\");\n                    jsx = \n`import React from 'react';\n\nconst ${componentName} = () => {\n    return (\n${jsx}\n    );\n};\n\nexport default ${componentName};\n`;\n                } catch (err) {\n                    console.log(contents);\n                    return Promise.reject();\n                }\n                \n                return write(path.join(destPath, pathname.replace(/\\.ss$/, '.js')), jsx);\n            })\n            .catch(console.error)\n    });\n\n    Promise.all(promises);\n});"]}