Skip to content

Commit 9dc2cc9

Browse files
committed
feat: wrap ignore file in a string
To allow this module to be webpacked
1 parent d3bedc5 commit 9dc2cc9

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
# Write glob rules for ignored files.
1+
exports.file = `# Write glob rules for ignored files.
22
# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-
33
# Check examples on https://github.com/github/gitignore
4+
`;

full.dcignore renamed to full.dcignore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Write glob rules for ignored files.
1+
exports.file = `# Write glob rules for ignored files.
22
# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-
33
# Check examples on https://github.com/github/gitignore
44
@@ -1597,3 +1597,4 @@ CATKIN_IGNORE
15971597
_build
15981598
_tracks
15991599
opa-debug-js
1600+
`;

generator/run.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -e
33

44
SCRIPT_DIR=$(dirname "$0")
55
SOURCE_DIR="./source"
6-
EMPTY_OUTPUT="../empty.dcignore"
7-
FULL_OUTPUT="../full.dcignore"
6+
EMPTY_OUTPUT="../empty.dcignore.js"
7+
FULL_OUTPUT="../full.dcignore.js"
88
REGEX="(^#.*)|((^|\/)\..*$)|(^.*\.[^\/]*$)|(.*src.*)|(^\/\*$)"
99

1010
cd "$SCRIPT_DIR"
@@ -16,14 +16,17 @@ else
1616
git clone https://github.com/github/gitignore.git $SOURCE_DIR
1717
fi
1818

19+
# Wrap generated string in a JS export
1920
TOP=(
20-
"# Write glob rules for ignored files."
21+
"exports.file = \`# Write glob rules for ignored files."
2122
"# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-"
2223
"# Check examples on https://github.com/github/gitignore"
2324
)
2425
for ELEMENT in "${TOP[@]}"; do
2526
echo -e "$ELEMENT"
2627
done > "$EMPTY_OUTPUT"
28+
echo -e "\`;" >> "$EMPTY_OUTPUT"
29+
2730
for ELEMENT in "${TOP[@]}"; do
2831
echo -e "$ELEMENT"
2932
done > "$FULL_OUTPUT"
@@ -53,6 +56,8 @@ find $SOURCE_DIR -name '*.gitignore' | while read file; do
5356
fi
5457
done
5558

59+
echo -e "\`;" >> "$FULL_OUTPUT"
60+
5661
cd ..
5762
echo "Parsing completed. Check '$(pwd)/$(basename $FULL_OUTPUT)' file for results."
5863
exit 0

index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const DefaultDCIgnore = fs.readFileSync(path.resolve(__dirname, 'full.dcignore'), 'utf8');
4-
const CustomDCIgnore = fs.readFileSync(path.resolve(__dirname, 'empty.dcignore'), 'utf8');
1+
const { file: DefaultDCIgnore } = require('./full.dcignore.js');
2+
const { file: CustomDCIgnore } = require('./empty.dcignore.js');
3+
54
module.exports = {
65
DefaultDCIgnore,
7-
CustomDCIgnore
6+
CustomDCIgnore,
87
};

0 commit comments

Comments
 (0)