-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72aede3
commit 145fd84
Showing
2 changed files
with
54 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
const fs = require('fs'); | ||
|
||
const encoding = "utf8"; | ||
const folder = `${__dirname}/../`; | ||
const packageName = 'svg' | ||
|
||
const getVersion = (overridePackageName) => { | ||
const pName = overridePackageName || packageName; | ||
const file = fs.readFileSync(`${folder}${pName}/package.json`, { encoding }); | ||
return JSON.parse(file).version; | ||
}; | ||
|
||
const getMeta = (withPaths, overridePackageName) => { | ||
const pName = overridePackageName || packageName; | ||
const file = fs.readFileSync(`${folder}${pName}/meta.json`, { encoding }); | ||
const meta = JSON.parse(file); | ||
if (withPaths) { | ||
const total = meta.length; | ||
meta.forEach((icon, i) => { | ||
const svg = fs.readFileSync(`${folder}${pName}/svg/${icon.name}.svg`, { encoding }); | ||
icon.path = svg.match(/d="([^"]+)"/)[1]; | ||
}); | ||
} | ||
return meta; | ||
}; | ||
|
||
exports.getVersionLight = () => { | ||
return getVersion('light-svg'); | ||
} | ||
|
||
exports.getMetaLight = (withPaths) => { | ||
return getMeta(withPaths, 'light-svg'); | ||
} | ||
|
||
exports.getVersion = getVersion; | ||
|
||
exports.getMeta = getMeta; | ||
|
||
exports.closePath = (path) => { | ||
return path.replace(/(\d)M/g, '$1ZM'); | ||
}; | ||
|
||
exports.write = (file, data) => { | ||
fs.writeFileSync(file, data); | ||
}; | ||
|
||
exports.read = (file) => { | ||
fs.readFileSync(file); | ||
}; | ||
|
||
exports.exists = (file) => { | ||
return fs.exists(file); | ||
}; | ||
const fs = require('fs'); | ||
|
||
const encoding = "utf8"; | ||
const folder = `${__dirname}/../`; | ||
const packageName = 'svg' | ||
|
||
const getVersion = (overridePackageName) => { | ||
const pName = overridePackageName || packageName; | ||
const file = fs.readFileSync(`${folder}${pName}/package.json`, { encoding }); | ||
return JSON.parse(file).version; | ||
}; | ||
|
||
const getMeta = (withPaths, overridePackageName) => { | ||
const pName = overridePackageName || packageName; | ||
const file = fs.readFileSync(`${folder}${pName}/meta.json`, { encoding }); | ||
const meta = JSON.parse(file); | ||
if (withPaths) { | ||
const total = meta.length; | ||
meta.forEach((icon, i) => { | ||
const svg = fs.readFileSync(`${folder}${pName}/svg/${icon.name}.svg`, { encoding }); | ||
icon.path = svg.match(/ d="([^"]+)"/)[1]; | ||
}); | ||
} | ||
return meta; | ||
}; | ||
|
||
exports.getVersionLight = () => { | ||
return getVersion('light-svg'); | ||
} | ||
|
||
exports.getMetaLight = (withPaths) => { | ||
return getMeta(withPaths, 'light-svg'); | ||
} | ||
|
||
exports.getVersion = getVersion; | ||
|
||
exports.getMeta = getMeta; | ||
|
||
exports.closePath = (path) => { | ||
return path.replace(/(\d)M/g, '$1ZM'); | ||
}; | ||
|
||
exports.write = (file, data) => { | ||
fs.writeFileSync(file, data); | ||
}; | ||
|
||
exports.read = (file) => { | ||
fs.readFileSync(file); | ||
}; | ||
|
||
exports.exists = (file) => { | ||
return fs.exists(file); | ||
}; |