import { copySync , ensureDirSync , ensureSymlinkSync , moveSync , pathExistsSync , readdirSync , readFileSync , removeSync , renameSync , writeFileSync } from 'fs-extra' ; export { copySync , removeSync , readFileSync , writeFileSync , readdirSync , ensureDirSync , renameSync , pathExistsSync , ensureSymlinkSync , moveSync } ; import * as helpers from '../helpers' ; import * as path from './path' ; param { ... string } resource export function clone ( ... resource ) { const source = path . flagship . resolve ( ... resource ) ; const destination = path . project . resolve ( ... resource ) ; helpers . logInfo ( `cloning ${ helpers . colors . Dim }${ source }${ helpers . colors . Reset } => ` + `${ helpers . colors . Dim }${ destination }${ helpers . colors . Reset }` ) ; copySync ( source , destination ) ; } param { string } path param { string } oldText param { string } newText export function update ( path , oldText , newText ) { if ( ! doesKeywordExist ( path , oldText ) ) { return helpers . logError ( `Couldn't find ${ oldText } in ${ path }` ) ; } const fileContent = readFileSync ( path , { encoding : 'utf8' } ) ; helpers . logInfo ( `updating ${ helpers . colors . Dim }${ path }${ helpers . colors . Reset }` ) ; writeFileSync ( path , fileContent . replace ( oldText , newText ) ) ; } param { string } path param { string } keyword returns { boolean } export function doesKeywordExist ( path , keyword ) { const fileContent = readFileSync ( path , { encoding : 'utf8' } ) ; if ( typeof keyword === 'string' ) { return fileContent . indexOf ( keyword ) > - 1 ; } else { return keyword . test ( fileContent ) ; } }