From e14444d371714114618ee8991ceb2c829e63b882 Mon Sep 17 00:00:00 2001 From: David Pichsenmeister Date: Mon, 29 Jun 2020 18:15:54 -0700 Subject: [PATCH] fixed file path issue --- README.md | 8 +------- index.js | 27 ++++++++++++++++++--------- package.json | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4e7e71d..1e440bb 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,6 @@ WienerScript requires [Node.js and npm](https://nodejs.org/en/). npm install -g wienerscript ``` -or - -``` -yarn add global wienerscript -``` - Usage: ``` @@ -133,4 +127,4 @@ Examples can be found in the [examples](examples) directory. This project is licensed under the MIT license, Copyright (c) 2020 David Pichsenmeister | [pichsenmeister.com](https://pichsenmeister.com). For more information see [LICENSE](LICENSE). -Made by [@pichsenmeister](https://twitter.com/pichsenmeister). Inspired by [ArnoldJS](https://github.com/pichsenmeister/ArnoldJS). +Made by [@pichsenmeister](https://twitter.com/pichsenmeister). Inspired by [ArnoldJS](https://github.com/theBrianCui/ArnoldJS). diff --git a/index.js b/index.js index bc7dbc7..7a130a4 100644 --- a/index.js +++ b/index.js @@ -7,12 +7,13 @@ const mkdirp = require('mkdirp') const prettier = require('prettier') // options is optional -const getFiles = () => { - return glob.sync("**/*.ws") +const getFiles = (currentPath) => { + const files = glob.sync(currentPath + "/**/*.ws") + return files.filter(file => file.indexOf('node_modules/') < 0) } const compile = (content) => { - const keywords = JSON.parse(fs.readFileSync('keywords.json', 'utf8')) + const keywords = JSON.parse(fs.readFileSync(path.join(__dirname, 'keywords.json'), 'utf8')) for (const key in keywords) { content = content.replace(new RegExp(key, "g"), keywords[key]); } @@ -20,18 +21,26 @@ const compile = (content) => { } const run = () => { - const files = getFiles() + console.log('HAWIDERE') + const currentPath = process.cwd() + const files = getFiles(currentPath) + + console.log('DO HOBN MA ' + files.length + ' GSCHICHTLN') + files.forEach(file => { - const content = fs.readFileSync(path.normalize(path.join(__dirname, file)), 'utf8') - const dir = path.join(__dirname, 'dist') + const content = fs.readFileSync(path.normalize(file), 'utf8') + const dir = path.join(currentPath, 'dist') if (!fs.existsSync(dir)) fs.mkdirSync(dir) - const dirs = file.substring(0, file.lastIndexOf(path.sep)) - mkdirp.sync(path.join(__dirname, 'dist', dirs)) + const dirs = file.substring(0, file.lastIndexOf(path.sep)).replace(currentPath, '') + mkdirp.sync(path.join(currentPath, 'dist', dirs)) - const filePath = path.join(__dirname, 'dist', file.replace('.ws', '.js')) + const filePath = path.join(currentPath, 'dist', file.replace(currentPath, '').replace('.ws', '.js')) + console.log('DRAH DI DEPATTA', file.replace(currentPath, '').replace(path.sep, '') + ' ==> ' + filePath.replace(currentPath, '').replace(path.sep, '')) fs.writeFileSync(filePath, prettier.format(compile(content), { parser: 'babel' }), (error) => console.error(error)) }) + + console.log('PFIATI') } run() \ No newline at end of file diff --git a/package.json b/package.json index 8c4a906..9dfd562 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wienerscript", - "version": "1.0.0", + "version": "1.0.1", "description": "WienerScript adds syntactic WIENERISCH to JavaScript that makes it less forgiving, more emotional, and even painful to write, allowing you to do less with more code.", "main": "./index.js", "bin": {