Browse Source

输出 JSON 文件

modood 8 years ago
parent
commit
d6be912f92
2 changed files with 8 additions and 20 deletions
  1. 7 4
      index.js
  2. 1 16
      output.js

+ 7 - 4
index.js

@@ -107,10 +107,13 @@ function getAddressPCAS () {
  * @DateTime 2016-10-08 17:16
  */
 function outputJSON () {
-  fs.writeFileSync(path.resolve(__dirname, 'dist/provinces.json'), JSON.stringify(getProvinces()))
-  fs.writeFileSync(path.resolve(__dirname, 'dist/cities.json'),    JSON.stringify(getCities()))
-  fs.writeFileSync(path.resolve(__dirname, 'dist/areas.json'),     JSON.stringify(getAreas()))
-  fs.writeFileSync(path.resolve(__dirname, 'dist/streets.json'),   JSON.stringify(getStreets()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/provinces.json'),        JSON.stringify(getProvinces()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/cities.json'),           JSON.stringify(getCities()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/areas.json'),            JSON.stringify(getAreas()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/streets.json'),          JSON.stringify(getStreets()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/address_p_c.json'),      JSON.stringify(getAddressPC()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/address_p_c_a.json'),    JSON.stringify(getAddressPCA()))
+  fs.writeFileSync(path.resolve(__dirname, 'dist/address_p_c_a_s.json'),  JSON.stringify(getAddressPCAS()))
   console.log('It\'s saved!')
 }
 

+ 1 - 16
output.js

@@ -1,19 +1,4 @@
 'use strict'
 
-const fs = require('fs')
-const path = require('path')
-
-const getProvinces = require('.').getProvinces
-
-/**
- * 输出 JSON 文件
- * @Author   https://github.com/modood
- * @DateTime 2016-10-08 17:16
- */
-function outputJSON () {
-  fs.writeFileSync(path.resolve(__dirname, 'dist/provinces.json'), JSON.stringify(getProvinces()))
-  console.log('It\'s saved!')
-}
-
-outputJSON()
+require('.').outputJSON()