haterapps / fake-data

Fake Data - A form filler you won't hate
39 stars 2 forks source link

custom generator for car VINs #1

Closed srzlt closed 4 years ago

srzlt commented 4 years ago

hi!

I tried to seutp a custom generator for VINs by integrating the vin generator from https://github.com/ArchmageInc/vin-generator. Unfortunately I get errors when I try to execute

var vinGenerator = require('vin-generator');
var randomVin = vinGenerator.generateVin();
return randomVin;

I think this is because of the multiple dependencies that vin-generator has on https://github.com/ArchmageInc/vin-generator/blob/master/vin-generator.js , https://github.com/ArchmageInc/vin-generator/blob/master/prefixes.js and https://raw.githubusercontent.com/lodash/lodash/4.17.15-npm/lodash.js

I also tried to unify all scripts into 1 js file, but could not get it to work either.

I am rather a newbie, could you give me a tip where to start to make it work?

Cheers Ilja

haterapps commented 4 years ago

Hello Ilja,

In order to make the script work you have to unify all 3 files into one, like you tried, but also remove the "module export" and "require" keywords and convert them to non ES6 modules.

Below is the updated version of your VIN generator script that works with Fake Data: https://gist.github.com/haterapps/db74d5c58ffb2a2c7afba88fe9095964

Also, if you have a pro license I would recommend you to load loadash library into Fake Data by going to Settings -> Developer Options -> Loaded Libraries. You will be able to reuse it again without having to unify it in other Generators.

Let me know if the above code works.