ng-tailor
Version:
This is a tailor who helps us customise our projects. In this very initial version(1.x), there is only one thing that this tailor adjust the Angular's HttpClient, then we can easily change the baseUrl of requesting an API in `./environments/environmen.ts`
42 lines (37 loc) • 1.22 kB
JavaScript
const fs = require('fs')
const path = require('path')
const templatesDir = path.resolve(__dirname, './templates')
const app_module_path = templatesDir + '/app.module.template'
const api_url_interceptor_path = templatesDir + '/api-url-interceptor.template'
const environment_path = templatesDir + '/environment.template'
const http_interceptors_index_path =
templatesDir + '/http-interceptors-index.template'
const app_module_template = fs.readFileSync(app_module_path, 'utf8')
const api_url_interceptor_template = fs.readFileSync(
api_url_interceptor_path,
'utf8'
)
const environment_template = fs.readFileSync(environment_path, 'utf8')
const http_interceptors_index_template = fs.readFileSync(
http_interceptors_index_path,
'utf8'
)
fs.mkdirSync('./src/app/http')
fs.mkdirSync('./src/app/http-interceptors')
fs.writeFileSync(
'./src/app/http/api-url-interceptor.ts',
api_url_interceptor_template,
'utf8'
)
fs.writeFileSync(
'./src/app/http-interceptors/index.ts',
http_interceptors_index_template,
'utf8'
)
fs.writeFileSync(
'./src/environments/environment.ts',
environment_template,
'utf8'
)
fs.writeFileSync('./src/app/app.module.ts', app_module_template, 'utf8')