Last active
February 16, 2019 00:52
-
-
Save paxperscientiam/40b696d1877d630f7efec8b42b3e656d to your computer and use it in GitHub Desktop.
[Pro-tip][macOS][iCloud] Renaming components directories for compatibility with iCloud on macOS ~10.14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By default, it's a bad idea to store component heavy projects in an iCloud syncronized directory as the frequent shuffling of hundreds of files puts a heavy burden on the sync service. Moreover, it gets in the way of keeping the important stuff syncronized. | |
Let's say your project structure looks like this: | |
~/Documents/project/ | |
└── node_modules | |
Let's adopt it accordingly: | |
~/Documents/project/ | |
└── modules.noSync | |
└── node_modules | |
Any directory name suffixed with ".noSync" will be ignored by iCloud sync. In our case, this will prevent updating/uninstalling/installing libraries from burdening sync services as child directories of "modules.noSync" are ignored. | |
Important consideration: you will almost definitely have to adopt your project settings to account for this tweak. | |
For example, `yarn` users should tweak their `.yarnrc` by adding the following line: | |
`--modules-folder "./modules.noSync/node_modules"` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Req(base) { | |
this.base = base; | |
} | |
Req.prototype.get = function(module, opts) { | |
if (typeof require(path.resolve(this.base, module)) === 'function' && opts !== undefined) { | |
return require(path.resolve(this.base, module))(opts) | |
} else { | |
return require(path.resolve(this.base, module)) | |
} | |
process.exit() | |
} | |
// EG | |
const req = new Req("./node_modules.noSync/node_modules") | |
const somePlugin = req.get("SomePlugin") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Honestly, this isn't really recommended. Though, you might have a reason.