1.0.4 • Published 2 years ago

svg-id v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

ez replace

utils functions to rename, replace with fs library

Installation

npm i svg-id 

Usage

// in index
import { readdirSync } from 'fs';
import { resolve } from 'path';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { replaceX, renameFile, replaceSVGID1, replaceSvgIds } from 'svg-id'; 

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// Get path to files directory 
const filesDirPath = resolve(__dirname, "path/of/folder");

// Get an array of the files inside the folder 
const files = readdirSync(filesDirPath);

// find all occurence of regex and replace with last argument
replaceX(files, imageDirPath, /eg/g, 'toto'); 
// rename in folder all files like this -> toto-1.svg, toto-2.svg ect
renameFile('svg', 'toto', files, filesDirPath); 
// replace this id (SVGID_1) give by illustrator on svgs export
replaceSVGID1(files, filesDirPath); 
// clean and make unique id of defaut svgs illustrator's export like : id="a" xlink:href="#a" fill="url(#a)"
replaceSVGIds(files, filesDirPath); 
// then run your script
1.0.4

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago