From 7ebb55da28857c47241d4067d652e8bde798d64e Mon Sep 17 00:00:00 2001 From: F-loat Date: Fri, 21 Dec 2018 18:09:54 +0800 Subject: [PATCH] fix: rename and update .gitignore --- generator.js | 12 ++++++++---- template/common/.gitignore | 10 ---------- template/common/_gitignore | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) delete mode 100644 template/common/.gitignore create mode 100644 template/common/_gitignore diff --git a/generator.js b/generator.js index 6ae5ed5..af7c841 100644 --- a/generator.js +++ b/generator.js @@ -13,14 +13,18 @@ async function generate(dir, files, base = '') { nodir: true }).forEach(rawPath => { const sourcePath = path.resolve(dir, rawPath) + const filename = path.join(base, rawPath) + if (isBinary.sync(sourcePath)) { - files[path.join(base, rawPath)] = fs.readFileSync(sourcePath) // return buffer + files[filename] = fs.readFileSync(sourcePath) // return buffer } else { const content = fs.readFileSync(sourcePath, 'utf-8') if (sourcePath.indexOf('manifest.json') !== -1 || sourcePath.indexOf('pages.json') !== -1) { - files[path.join(base, rawPath)] = JSON.stringify(JSON.parse(stripJsonComments(content)), null, 2) + files[filename] = JSON.stringify(JSON.parse(stripJsonComments(content)), null, 2) + } else if (filename.charAt(0) === '_' && filename.charAt(1) !== '_') { + files[`.${filename.slice(1)}`] = content } else { - files[path.join(base, rawPath)] = content + files[filename] = content } } }) @@ -75,4 +79,4 @@ module.exports = (api, options, rootOptions) => { await generate(path.resolve(__dirname, './template/common'), files) }) -} +} diff --git a/template/common/.gitignore b/template/common/.gitignore deleted file mode 100644 index a65be9d..0000000 --- a/template/common/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.DS_Store -.project -.vscode - -node_modules/ -unpackage/ - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/template/common/_gitignore b/template/common/_gitignore new file mode 100644 index 0000000..e855477 --- /dev/null +++ b/template/common/_gitignore @@ -0,0 +1,22 @@ +.DS_Store +node_modules/ +unpackage/ + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.project +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw*