9 } from '../../src/Fig.js';
10 import stat from '../../src/fs/stat.js';
11 import path from '../../src/path.js';
13 variables(({identity}) => ({
14 gitUserEmail: identity === 'wincent' ? 'greg@hurrell.net' : '',
15 gitUserName: identity === 'wincent' ? 'Greg Hurrell' : '',
16 gitHubUsername: identity === 'wincent' ? 'wincent' : '',
19 task('make directories', async () => {
20 await file({path: '~/.backups', state: 'directory'});
21 await file({path: '~/.config', state: 'directory'});
22 await file({path: '~/.config/karabiner', state: 'directory'});
23 await file({path: '~/.mail', state: 'directory'});
24 await file({path: '~/.zshenv.d', state: 'directory'});
26 if (variable('identity') === 'wincent') {
27 await file({path: '~/code', state: 'directory'});
31 task('copy to ~/backups', async () => {
32 const files = [...variable.paths('files'), ...variable.paths('templates')];
34 for (const file of files) {
35 const base = file.basename;
36 const source = path.home.join(base);
37 const target = path.home.join('.backups', base);
39 const stats = await stat(source);
41 if (stats instanceof Error) {
45 } else if (stats.type === 'directory' || stats.type === 'file') {
46 await command('mv', ['-f', source, target], {
53 task('create symlinks', async () => {
54 const files = variable.paths('files');
56 for (const src of files) {
59 path: path.home.join(src.basename),
60 src: path.aspect.join('files', src.basename),
66 task('fill templates', async () => {
67 const templates = variable.paths('templates');
69 for (const src of templates) {
71 mode: src.endsWith('.sh.erb') ? '0755' : '0644',
72 path: path.home.join(src.basename.strip('.erb')),
73 src: path.aspect.join('templates', src.basename),
78 task('create ~/code/.editorconfig', async () => {
79 if (variable('identity') === 'wincent') {
81 path: path.home.join('code/.editorconfig'),
82 src: resource.template('code/.editorconfig'),